ubuntu postfix with gmail
1 min readAug 6, 2020
今日主題:SMTP Mail Server 寄信服務
# 安裝套件
sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules# 修改設定檔
vim /etc/postfix/main.cf# 加入下列設定
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes# 建立sasl_passwd
vim /etc/postfix/sasl_passwd# 加入下列設定
[smtp.gmail.com]:587 USERNAME@gmail.com:PASSWORD#Create a hash database file for Postfix
sudo postmap /etc/postfix/sasl_passwdsudo chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.dbsudo postmap /etc/postfix/sasl_passwdcat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/cacert.pem# 重啟服務
sudo service postfix restart# 測試寄信
echo “this is a test” | mailx -s “This is the subject” your-mail@example.com
憑證
cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/cacert.pem
— 完成 —