投稿日: | 最終更新日:
ローカル環境にメールサーバーを設定する
Webサイトのお問い合わせフォームや歳と管理者に通知するメール送信には、メールサーバーが必要です。XAMPPには、メールサーバーの「Mercury」が含まれます。しかし、Mercuryは設定が難しく、ローカルからのメール送信はプロバイダにブロックされたり、迷惑メールとしてブロックされる可能性が高いです。
そこで、XAMPPに同梱されているsendmail.exeを利用し、外部のメールサーバーを使います。
メールサーバー設定に必要な情報
1.必ず必要な情報
- ・メールアドレス
- ・SMTPサーバーホスト名(例:smtp.example.com)
- ・SMTPサーバーポート番号(例:25)
2.「POP BEFORE SMTP」の場合に追加で必要な情報
- ・POPサーバーホスト名(例:pop.example.com)
- ・POPサーバーユーザー名
- ・POPサーバーパスワード
3.「SMTP認証」の場合に追加で必要な情報
- ・POPサーバーユーザー名
- ・POPサーバーパスワード
メールサーバーは、以下の3つのいずれかに該当します。どのパターンに該当するか・どの情報が必要か確認しましょう。
手順
①メール送信サーバーの認証方式を確認
↓
②php.ini変更
↓
③sendmail.ini変更
↓
④XAMPP再起動
①まず、メール送信サーバーの認証方式を確認します。お使いのメールーのサーバー管理者(プロバイダ)に確認しましょう。以下の3つであればsendmail.exeが利用できます。
- ・認証不要
- ・POP BEFORE SMTP
- ・SMTP認証
Outlook、Thunderbirdなどの普通のメーラーであれば、この3つのいずれかに入ります。ただし、GmailのようにSSL/TLSでの暗号化された接続以外を受け付けないメールサーバーは利用できません。
※Gmailをメールサーバーとして利用する方法は別途説明します。
②php.iniを修正します。
パス例)C:\xampp\php\php.ini
(…略…) [mail function] ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury ; SMTP = localhost ; smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = xxxx@yyy.com ; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly. ; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path. ; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder) sendmail_path = “/”C:/xampp/endmail/sendmail.exe/” -t” (…略…)
(1)以下の2行をコメントアウトします。
;SMTP
;smtp_port = 25
(2)コメントアウトを解除して、自分のメールアドレスを記述します。
sendmail_from = xxxx@yyy.com
(3)コメントを解除します。
“/”C:/xampp/sendmail/sendmail.exe/” -t”
③sendmail.iniを修正します。
パス例)C:/xampp/sendmail/sendmail.ini
(…略…) [sendmail] ; you must change mail.mydomain.com to your smtp server, ; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) ; emails delivered via IIS's pickup directory cause sendmail to ; run quicker, but you won't get error messages back to the calling ; application. smtp_server=mail.mydomain.com ; smtp port (normally 25) smtp_port=25 (…略…) force_sender=xxxx@yyy.com (…略…)
(1)SMTPサーバーのホスト名を記述します。
smtp_server=mail.mydomain.com
(2)SMTPサーバーのポート番号を記述します。
smtp_port=25
(3)コメントを解除して自分のメールアドレスを記述します。
force_sender=xxxx@yyy.com
認証方式が「POP BEFORE SMTP」の場合
sendmail.iniを修正します。
(…略…) ; if your smtp server uses pop3 before smtp authentication, modify the ; following three lines. do not enable unless it is required. pop3_server=xxxx@yyy.com pop3_username=xxxxx pop3_password=xxxxx (…略…)
(1)POP3サーバーのホスト名を記述します。
pop3_server=xxxx@yyy.com
(2)POP3サーバーのユーザー名を記述します。
pop3_username=xxxxx
(3)POP3サーバーのパスワードを記述します。
pop3_password=xxxxx
認証方式が「SMTP認証」の場合
sendmail.iniを修正します。
(…略…) ; if your smtp server requires authentication, modify the following two lines auth_username=xxxxx auth_password=xxxxx (…略…)
(1)SMTPサーバーのユーザー名を記述します。
auth_usernamer=xxxxx
(2)SMTPサーバーのパスワードを記述します。
auth_password=xxxxx
④Apacheを再起動します。コントロールパネルからStopボタンを押して、再度Startボタンをクリックします。
- Python 114
- 制作 54
- RaspberryPi 41
- Django 40
- WordPress 40
- Linux 27
- VPS 22
- JavaScript 21
- PHP 20
- HTML・CSS 19
- AWS 16
- 仮想環境 15
- レスポンシブデザイン 13
- マイコン 11
- WEB全般 11
- 動画製作 9
- Webサービス 8
- 統合開発環境 8
- 機械学習 8
- PyCharm 7
- jQuery 7
- AfterEffects 7
- 起業・設立 7
- Django REST framework 6
- C# 6
- デザイン 6
- SEO 6
- pydata 6
- Visual Studio 5
- 数学 5
- 携帯サイト 5
- heroku 5
- Mac 5
- illustrator 5
- node.js 5
- Anaconda 5
- Nginx 4
- Jupyter Notebook 4
- インフラ 4
- Google Colaboratory 4
- symfony 4
- Webスクレイピング 3
- photoshop 3
- Go言語 3
- PC 3
- ツール 3
- Docker 3
- facebook 3
- 作業効率化 3
- データベース 3
- Cloud9 3
- コマンド 2
- micro:bit 2
- Kali Linux 2
- Webサーバー 2
- MariaDB 2
- ドローン 2
- コンテナ 2
- DaVinci Resolve 2
- ネットワーク 2
- Java 2
- movie 2
- PCDJ 2
- 音楽 2
- XSERVER 2
- Ansible 1
- Vue.js 1
- JSON 1
- Bootstrap 1
- バージョン管理システム 1
- SSL 1
- S3 1
- ムームードメイン 1
- ネットワーク 1
- アニメーション 1
- D3.js 1
- Rhino 1
- アニメ 1
- git 1
- windows 1
- アクセス解析 1
- スマートフォン 1
- アフィリエイトノウハウ 1
- 知識 1
- TypeScript 1
- 役立つ本・書籍 1
- データサイエンス 1
- ESP32 1
- AI 1
- ownCloud 1
- API 1