3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MACでPHPからMailHogにメールを投げてみる設定

Last updated at Posted at 2019-11-21

ローカル環境で手軽にメールテストをしたい時、windowsだと「smtp4dev」を使っていたけでれど、MACやLinuxでないかなと探したら、MailHogがあった。
mailcatcherだとruby入れないとだけれど、MailHogはバイナリファイルなので便利。

MailHogインストール

brew update && brew install mailhog
実行
mailhog

sendmailの設定

設定ファイルを編集
sudo vim /etc/postfix/main.cf

以下の行を追加

main.cf
relayhost = [0.0.0.0]:1025

チェック
sudo postfix check

phpでテスト

以下のテスト用ファイルを作成

mailtest.php
<?php
mail('test@example.com', 'subject', 'body');

実行
php mailtest.php

#MailHogで確認
http://localhost:8025/

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?