Skip to content

Instantly share code, notes, and snippets.

@kyoh86
Last active May 6, 2016 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyoh86/8f80ee5dc1a9c0e2a39aaa5b7bbac120 to your computer and use it in GitHub Desktop.
Save kyoh86/8f80ee5dc1a9c0e2a39aaa5b7bbac120 to your computer and use it in GitHub Desktop.
PHP+postfix with Gmail on El Capitan ref: http://qiita.com/kyoh86/items/c09224660da7ed618afd
[smtp.gmail.com]:587 hoge@hoge.com:hogehogehoge
sudo postmap hash:/etc/postfix/sasl_passwd
sudo postfix reload
sudo postfix stop
sudo postfix start
sudo postmap hash:/etc/postfix/sasl_passwd
sudo postfix reload
sudo postfix stop
sudo postfix start
sudo postmap hash:/etc/postfix/sasl_passwd
sudo postfix reload
sudo postfix stop
sudo postfix start
```sample.php
<?php
date_default_timezone_set('Asia/Tokyo');
mb_send_mail(
"hoge@hoge.com",
"test for postfix",
"test for PHP+postfix with Gmail on El Capitan",
"From: hoge@hoge.com"
);
?>
```
# :
# : 前略
# :
# CUSTOM ########
# Minimum Postfix-specific configurations.
mail_owner = _postfix
setgid_group = _postdrop
myhostname = smtp.gmail.com
relayhost=[smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
smtp_use_tls = yes
smtp_sasl_mechanism_filter = plain
;
; 前略
;
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = hoge@hoge.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail -t -i
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
<?php
date_default_timezone_set('Asia/Tokyo');
mb_send_mail(
"hoge@hoge.com",
"test for postfix",
"test for PHP+postfix with Gmail on El Capitan",
"From: hoge@hoge.com"
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment