Does it have to be authenticated?  Assuming that your users receive internet 
mail on the office365 box, you could just set the postfix host to send on port 
25.  You can limit what it will relay to mail from your internal subnets so it 
isn't an open relay and it can pass anything from your printers, etc. to the 
office365 host.

Another option might be to configure your printers/applications to send to the 
office365 host.  If it accepts mail from the world at large on port 25, I don't 
see why it couldn't from your internal hosts as well.  But you may have 
perfectly good reasons for not wanting to do that, every site is different...

...Kevin
--
Kevin Miller
Network/email Administrator, CBJ MIS Dept.
155 South Seward Street
Juneau, Alaska 99801
Phone: (907) 586-0242, Fax: (907) 586-4588 Registered Linux User No: 307357


-----Original Message-----
From: owner-postfix-us...@postfix.org [mailto:owner-postfix-us...@postfix.org] 
On Behalf Of jdehnert
Sent: Wednesday, January 11, 2017 2:43 PM
To: postfix-users@postfix.org
Subject: RE: Forwarding all mail to office365.com exchange server.

Kevin Miller wrote
> I can't speak for anyone else, but your original post doesn't seem to 
> have made it to the list.
> 
> The one that came in an hour ago to which Noel replied had no details, 
> and it had a "re:" in the subject line indicating it was part of a 
> thread containing other messages but none of the other messages made 
> it to the postfix list, hence the comment that nobody knows what 
> you're talking about.  Or at least none of the other messages made it 
> to my feed. Whether others saw the original post or not I can't say...
> 
> ...Kevin

Well, That explains alot.  

I will repost here.

I know I am not the only person who has tried to do this, but I seem to be 
having all kinds of trouble making it happen. 

My company has switched over to use the Office365.com Exchange server as it's 
mail server. 

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. 

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
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.

Reply via email to