0% found this document useful (0 votes)
49 views

Configuring Postfix As Email Relay For Office 365 - Geekdudes

Uploaded by

Jinu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Configuring Postfix As Email Relay For Office 365 - Geekdudes

Uploaded by

Jinu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

8/16/2020 Configuring Postfix as email relay for Office 365 | geekdudes

geekdudes

IT Tips&Tricks
stay updated via rss

Configuring Postfix as email relay for Office 365

Posted: April 11, 2018 in Linux


12
Install sasld

yum install cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5


systemctl start saslauthd

in /etc/postfix folder create file sasl_passwd and put username and password of mailbox which will
be used as relay

[smtp.office365.com]:587 [email protected]:Pass

To set default “from” to be this email open file /etc/postfix/generic

Add this at bo om (this is amazon AWS instance)

[email protected] [email protected]

All emails will be rewri en with in from field with one we just specified

postmap hash:/etc/postfix/sasl_passwd
postmap hash:/etc/postfix/generic

now add following lines in /etc/postfix/main.cf

https://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ 1/5
8/16/2020 Configuring Postfix as email relay for Office 365 | geekdudes

relayhost = [smtp.office365.com]:587
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_auth_enable = yes
smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_security_level = may
smtp_sasl_security_options = noanonymous

Restart postfix service and you should be able to send emails through Office 365

If you get “Office 365 unreachable” error, in /etc/postfix/main.cf


change inet_protocols line from all to ipv4

Certificate authentication

If we want to secure our connection we can secure it with certificate:

openssl s_client -showcerts -starttls smtp -crlf -connect smtp.office365.com:587

In my case i got 2 certificates, i copied it in cacert.pem file

https://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ 2/5
8/16/2020 Configuring Postfix as email relay for Office 365 | geekdudes

then add following lines to /etc/postfix/main.cf

smtp_send_dummy_mail_auth = yes
smtp_always_send_ehlo = yes
smtp_tls_security_level = encrypt
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem

Restart postfix service and your traffic is now encrypted

Comments

https://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ 3/5
8/16/2020 Configuring Postfix as email relay for Office 365 | geekdudes

Configure Postfix MTA to Office 365 on CentOS 7 – Sysadmin Soup says:


January 16, 2019 at 1:58 am
[…] to h ps://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ for
this […]

Reply
Jordan Acosta says:
February 5, 2019 at 12:03 am
Muchas gracias, funciono perfecto con esta documentacion.

Reply
Mikhail says:
March 25, 2019 at 4:56 pm
Great instruction! helped me a lot!

Reply
Tamás Bors says:
August 2, 2019 at 2:48 pm
I did everything, but I got this error when sending email:

relay=smtp.office365.com[40.97.135.146]:587, delay=2.3, delays=0.04/0/1.9/0.37, dsn=5.2.0,


status=bounced (host smtp.office365.com[40.97.135.146] said: 554 5.2.0
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to
process message due to a permanent exception with message Cannot submit message

and also this (but this is a warning)


Aug 2 09:45:35 learning postfix/smtp[13847]: warning: network_biopair_interop: error writing 37
bytes to the network: Connection reset by peer

any ideas?
thank you

Reply
dragan979 says:
August 2, 2019 at 7:38 pm
according to error it seems account you’re using have no send as permissions, go to Office 365
console and check mailbox permissions.

Can you send emails from that account from outlook/OWA ?

Reply

Hasanain says:
April 29, 2020 at 12:06 pm
I have Microsoft SMTP relay server and i need to shift CentOS 8 server to be as SMTP relay server
and i found POSTFIX tool to work as relay.
i need to install fresh installation& configuration of PostFix in CentOS 8 to be SMTP relay and
integrate with Office365.
any help?

Reply
https://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ 4/5
8/16/2020 Configuring Postfix as email relay for Office 365 | geekdudes

dragan979 says:
April 29, 2020 at 4:09 pm
My post is just about that topic

Reply
Brent Gunn says:
June 23, 2020 at 2:39 pm
I have completed this configuration and I have positive mail flow…the message is received by O365
BUT the message is delivered to the LOGIN email address instead of the actual recipient email
specified. I am unable to figure out what is causing this to occur.

Reply
Brian L. Lawson says:
June 24, 2020 at 7:43 pm
You said you got 2 certs and you, “…copied it in cacert.pem file.” Which one did you copy? If both,
just one right after the other?
thanks

Reply
dragan979 says:
June 24, 2020 at 7:45 pm
both

Reply
Chakib Karym says:
July 1, 2020 at 11:26 am
what does this command do : [email protected] [email protected]

what are the parameters to change in this comman so it works for me?

Thanks.

Reply
dragan979 says:
July 1, 2020 at 12:39 pm
This is not command but string added to /etc/postfix/generic to identify machine from which
emails are sent.

Reply

Blog at WordPress.com.

https://geekdudes.wordpress.com/2018/04/11/configuring-postfix-as-relay-for-office-365/ 5/5

You might also like