ホーム >  WordPress >  ローカル環境にメールサーバーを設定する

投稿日:   |  最終更新日:

ローカル環境にメールサーバーを設定する

WordPress制作

 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ボタンをクリックします。

xammp_010
 

トラックバック用のURL
プロフィール

名前:イワサキ ユウタ 職業:システムエンジニア、ウェブマスター、フロントエンドエンジニア 誕生:1986年生まれ 出身:静岡県 特技:ウッドベース 略歴 20

最近の投稿
人気記事
カテゴリー
広告