LoginSignup
32

More than 5 years have passed since last update.

MacでPostfixを使ってGmail経由でテストメールを送信

Last updated at Posted at 2012-12-07

環境

Mac OSX 10.8.2, Postfix

Postfixを起動してみる
$ sudo postfix start

Postfixの設定

$ sudo vi /etc/postfix/main.cf

リレーホストを追加する

relayhost = [smtp.gmail.com]:587

設定ファイルの最後に下記を追記する

#sasl setting
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain

#tls setting
smtp_use_tls = yes

メールのローカル配送をMaildir形式にする

home_mailbox = Maildir/
#mail_spool_directory = ...
#mailbox_command = ...

Gmailのアカウント情報を作成

sudo vi /etc/postfix/sasl_passwd  #新規作成

アカウント情報を記述する

[smtp.gmail.com]:587 hogehoge@gmail.com:(password)

適切な権限を設定し postmap をかける

chmod 640 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Maildirの作成

$ sudo mkdir /home/hogehoge/Maildir
$ sudo chown -R hogehoge:staff /home/hogehoge/Maildir
$ sudo chmod 700 /home/hogehoge/Maildir

最後にPostfixを再起動して終了

sudo postfix stop
sudo postfix start

[参考]
http://weble.org/2012/05/10/mac-postfix
http://d.hatena.ne.jp/ramtiga/20110411/p1
http://snbhsmt.blog110.fc2.com/blog-entry-42.html

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
32