I have several things like printers and applications that send email to a local linux host running postfix, and I need to get that postfix instance to
forward all of its email to the Office365.com Exchange server via an
authenticated connection. I have an account that we have used for system
email previously.  It's set up as a normal email user.

I have configured postfix so that it will not deliver any mail locally.

I have set the relayhost to

    [smtp.office365.com]:587

I have created a smtp_sasl_passwd file that has the following contents
(redacted where necessary)

    [smtp.office365.com]:587    kem...@mydomain.com:PASSWORD

This connects just fine, and rewrites the mail sender when I send email from
the local postfix host.

I have added the following lines to main.cf to try and get mail from other
hosts to forward:

    sender_canonical_classes = envelope_sender,header_sender
    sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps

the sender_canonical_maps looks like this:

    /.+/        kem...@mydomain.com

and I have remembered to run postmap on all of the mapping file I have tried
over the last week or so of trying this.

but for some reason, no email from any other host or device ever gets
through.

Have you read http://www.postfix.org/ADDRESS_REWRITING_README.html ?

For better help show logs of one message that passes through your system.

If someone has a working example of a main.cf that is configured to relay
mail from local systems and devices to office365.com through an
authenticated connection, I would really love to see it.  I'm tired of
banging my head on the wall.

Below is my postconf -n output. I have tried several permutations on this, so just because you don't see something obvious in that info, believe me, I
probably tried it.

At any rate, anything I tried failed, so I'm ready to try out all
suggestions.

postconf -n output:

[2299]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debug_peer_list = smtp.office365.com
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd
$daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_protocols = all
local_recipient_maps =
local_transport = error:local mail delivery is disabled
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 20480000
mydestination =
myhostname = pet-mail-01.enphaseenergy.com
myorigin = enphaseenergy.com
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
relay_domains = enphaseenergy.com
relayhost = [smtp.office365.com]:587
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sender_canonical_classes = envelope_sender,header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps

Take a look at the documentation for sender_canonical_maps http://www.postfix.org/postconf.5.html#sender_canonical_maps and canonical_maps http://www.postfix.org/postconf.5.html#canonical_maps

I suspect you probably need to set local_header_rewrite_clients http://www.postfix.org/postconf.5.html#local_header_rewrite_clients for your rewriting of mails from remote hosts to be made.

sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_passwd
smtp_sasl_security_options =
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.trust.crt
smtp_tls_ciphers = export
smtp_tls_mandatory_ciphers = high
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = encrypt
smtp_use_tls = yes
unknown_local_recipient_reject_code = 550



-----
 Thanks,
    James "Zeke" Dehnert

--
mailto:jdehn...@dehnert.com  James "Zeke" Dehnert
                  -= Eschew Obfuscation =-
     "Life is racing. Everything else is just waiting"
--
View this message in context:
http://postfix.1071664.n5.nabble.com/Forwarding-all-mail-to-office365-com-exchange-server-tp87986p88226.html
Sent from the Postfix Users mailing list archive at Nabble.com.

--
 Christian Kivalo

Reply via email to