Below is a configuration I used to make postfix relay with office365

myhostname = pbx.domain.com
mydomain = domain.com
relayhost = [smtp.office365.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_tls_auth_only = yes
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 0
smtpd_tls_received_header = no
tls_random_source =
smtp_tls_CAfile =

 

If you are having trouble making outbound calls with megapath and getting a SIP 604 error. Go to outbound parameters and set all the parameters to the leave default value.