You would need a paid-for Microsoft email account to get this to work

systemctl stop postfix

dnf install postfix s-nail cyrus-sasl-plain

Insert the following at the end of the /etc/postfix/main.cf file

smtp_tls_security_level = may
meta_directory = /etc/postfix
shlib_directory = /usr/lib64/postfix

smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = smtpd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
smtp_use_tls = yes
relayhost = [smtp.office365.com]:587
smtp_sasl_auth_enable = yes
smtpd_relay_restrictions = ${{$compatibility_level} < {1} ? {} : {permit_mynetworks permit_sasl_authenticated defer_unauth_destination}}
mynetworks_style = host
myorigin = sitename.com

Create the credentials file in /etc/postfix/sasl_passwd: vim /etc/postfix/sasl_passwd

use the following data: [smtp.office365.com]:587 user@sitename.com:password

change the user to your user and password to your outlook password for that account in the information above

create the postmap file: postmap /etc/postfix/sasl_passwd

change permissions on the files: 

  • chmod 600 /etc/postfix/sasl_passwd
  • chmod 600 /etc/postfix/sasl_passwd.db

You can test this in the command shell: echo "Test body" | mail -s "Relay Test Email" kwjamie2@gmail.com

# Add ports permanently (retained after reboot)

  • firewall-cmd --permanent --add-port=25/tcp
  • firewall-cmd --permanent --add-port=587/tcp
  • firewall-cmd --permanent --add-port=465/tcp
  • firewall-cmd --permanent --add-port=143/tcp
  • firewall-cmd --permanent --add-port=993/tcp
  • firewall-cmd --permanent --add-port=110/tcp
  • firewall-cmd --permanent --add-port=995/tcp

# Reload firewalld to apply changes

  • firewall-cmd --reload
Posted: 03/28/2023 01:11:27 PM by: Jamie category: General