沒想到Google Cloud 竟然內建 不開放 發信port
詢問經銷商得知 發信只能用兩種方式 一種APP 一種RELAY Sendgrid
這次選用第二種作測試,請先行去 https://sendgrid.com/ 申請帳號密碼,等等在relay時會需要此組帳密作為登入
1.首先 先移除掉預設的sendmail 安裝 postfix
/etc/init.d/sendmail stop #停止sendmail
yum -y install postfix #安裝 要用的postfix
rpm -e sendmail #移除掉sendmail
service postfix start #出發吧 postfix
# cat > /etc/postfix/sasl_passwd << EOF
[smtp.sendgrid.net]:2525 YOUR_SENDGRID_USERNAME:YOUR_SENDGRID_PASSWORD
EOF
# postmap /etc/postfix/sasl_passwd
# ls -l /etc/postfix/sasl_passwd*
-rw------- 1 root root 68 Aug 1 09:50 /etc/postfix/sasl_passwd
-rw------- 1 root root 12288 Aug 1 09:51 /etc/postfix/sasl_passwd.db
# cat >> /etc/postfix/main.cf << EOF
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:2525
EOF
# yum install cyrus-sasl-plain
# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
# echo test | mail -s test xxx@gmail.com
# tail -n 5 /var/log/maillog
順帶一提
如果是要用php 來發信的,裝了postfix,請記得去php.ini
修改
sendmail_path = /usr/sbin/sendmail.postfix -t -i
留言列表