Search

Postfix Setup External SMTP

  • Share this:
post-title

1. Ensure your system is up-to-date:

apt-get update

apt-get upgrade

2. Install the libsasl2-modules

apt-get install libsasl2-modules

3. Installing Postfix

apt-get install postfix

General type of mail configuration is Internet Site and System mail name is fully qualified domain like mail.example.com

4. Update file  /etc/postfix/main.cf

myhostname = mail.example.com

5.  Create a like name sasl_password

nano /etc/postfix/sasl_passwd

and update as follwoing

[smtp.office.com] username:password

6. Create a Hash database file for Postfix using

postmap /etc/postfix/sasl_passwd

7. Run the following command to change file’s permissions

chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

8. Open /etc/postfix/main.cf and update as follwoing

nano /etc/postfix/main.cf

# specify SMTP relay host

relayhost = [smtp.office.com]:587

# 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

# Enable STARTTLS encryption

smtp_use_tls = yes

# where to find CA certificates

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

8. service postfix restart

Yusuf Khalil

Yusuf Khalil