Author Topic: postfix mail configure relaymail host to send email via mailgun  (Read 3170 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
postfix mail configure relaymail host to send email via mailgun
« on: สิงหาคม 07, 2018, 09:40:55 PM »
sudo apt-get update
sudo apt-get install postfix libsasl2-modules -y

###re-configure postfix
dpkg-reconfigure postfix
and choose “Internet-site”

###edit to use sasl
vi /etc/postfix/main.cf

# specify SMTP relay host
relayhost = [mail.isp.example]
# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd


#vi /etc/postfix/sasl_passwd
Add the following line to the new file:
/etc/postfix/sasl_password
smtp.mailgun.org your_mailgun_smtp_user@your_subdomain_for_mailgun:your_mailgun_smtp_password

Next, protect the file by restricting read and write permissions to root and and use the postmap command to update Postfix's lookup tables to use this new file:
#chmod 600 /etc/postfix/sasl_passwd
#postmap /etc/postfix/sasl_passwd

###Restart service postfix
/etc/init.d/postfix restart