Forwarding all mail to office365.com exchange server.

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Forwarding all mail to office365.com exchange server.

jdehnert
This post has NOT been accepted by the mailing list yet.
This post was updated on .
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	kemail@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:

    /.+/	kemail@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.

 Thanks,
    James "Zeke" Dehnert

--
mailto:jdehnert@dehnert.com  James "Zeke" Dehnert
                  -= Eschew Obfuscation =-
     "Life is racing. Everything else is just waiting"
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
Really?  No one has dealt with this issue?  Thats astonishing.

I would have expected this to have been done many times, to the point where it might even get documented on the Postfix web site (but I can't find it if it is).

I may have to abandon this project and look for some other tool, but I really believe postfix can do this.  I just can't seem to make it work.
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Noel Jones-2
On 1/11/2017 4:33 PM, jdehnert wrote:
> *Really?*  No one has dealt with this issue?  Thats astonishing.

No one knows what your issue is.

To report a problem with postfix, please see
http://www.postfix.org/DEBUG_README.html#mail

In particular, be sure to include "postconf -n" output and unedited
log entries of the problem.

DO NOT send verbose (-v) logs unless specifically requested.


  -- Noel Jones
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
Noel Jones-2 wrote
On 1/11/2017 4:33 PM, jdehnert wrote:
> *Really?*  No one has dealt with this issue?  Thats astonishing.

No one knows what your issue is.
Hmm, I thought I was clear with my post, but I guess I was not clear enough.   I should have posted the postconf -n output, but I was hoping that someone had done this before and could perhaps just offer up the proper mapping information that I seem to be missing.

Please forgive my assumptions.  I really do need some help with this as no matter what mappings I try I never seem to get things to work.

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:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

RE: Forwarding all mail to office365.com exchange server.

Kevin Miller
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
--
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: [hidden email] [mailto:[hidden email]] On Behalf Of jdehnert
Sent: Wednesday, January 11, 2017 1:52 PM
To: [hidden email]
Subject: Re: Forwarding all mail to office365.com exchange server.

Noel Jones-2 wrote
> On 1/11/2017 4:33 PM, jdehnert wrote:
>> *Really?*  No one has dealt with this issue?  Thats astonishing.
>
> No one knows what your issue is.

Hmm, I thought I was clear with my post, but I guess I was not clear enough.  
I should have posted the postconf -n output, but I was hoping that someone had done this before and could perhaps just offer up the proper mapping information that I seem to be missing.

Please forgive my assumptions.  I really do need some help with this as no matter what mappings I try I never seem to get things to work.

postconf -n output:





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

--
mailto:[hidden email]  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-tp87986p88223.html
Sent from the Postfix Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

RE: Forwarding all mail to office365.com exchange server.

jdehnert
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 kemail@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:

    /.+/ kemail@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:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

RE: Forwarding all mail to office365.com exchange server.

Kevin Miller
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: [hidden email] [mailto:[hidden email]] On Behalf Of jdehnert
Sent: Wednesday, January 11, 2017 2:43 PM
To: [hidden email]
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 [hidden email]: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:

    /.+/ [hidden email]

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:[hidden email]  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 | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Igor Golubkov
In reply to this post by jdehnert
Only problem I had with office 365 is old postfix version in CentOS 6 repos. After building newer version all worked as it should.

чт, 12 янв. 2017 г. в 2:43, jdehnert <[hidden email]>:
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    [hidden email]: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:

    /.+/        [hidden email]

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:[hidden email]  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 | Threaded
Open this post in threaded view
|

RE: Forwarding all mail to office365.com exchange server.

jdehnert
In reply to this post by Kevin Miller
Kevin Miller wrote
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
It does need to be authenticated because we have several mailing groups that will not accept mail from external sources.  They will accept mail from all authenticated users, so mail comping in on port 25 doesn't make the cut.
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
In reply to this post by Igor Golubkov
Igor Golubkov wrote
Only problem I had with office 365 is old postfix version in CentOS 6
repos. After building newer version all worked as it should.
I'm running this in a Centos 7.2 system, but the Postfix version is a rather old 2.10.1

Would moving up to Postfix 3.1 help?

I hate breaking the package manager by installing from source, but if 3.1 can resolve my issues I will give it a try.

Can you tell me what mapping you use to change the user in the envelope on the incoming email?
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Peter Ajamian
On 12/01/17 13:14, jdehnert wrote:
> I'm running this in a Centos 7.2 system, but the Postfix version is a rather
> old 2.10.1
>
> Would moving up to Postfix 3.1 help?
>
> I hate breaking the package manager by installing from source, but if 3.1
> can resolve my issues I will give it a try.

No need to install from source, you can get postfix 3.1 packages for
CentOS here:
http://ghettoforge.org/index.php/Postfix3

That said, I don't see any reason why Postfix 2.10 can't relay to office
365.  Can you please show relevant postfix logs of an attempt at such?


Peter
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Viktor Dukhovni
In reply to this post by jdehnert
On Wed, Jan 11, 2017 at 03:33:40PM -0700, jdehnert wrote:

> *Really?*  No one has dealt with this issue?  Thats astonishing.
>
> I would have expected this to have been done many times, to the point where
> it might even get documented on the Postfix web site (but I can't find it if
> it is).
>
> I may have to abandon this project and look for some other tool, but I
> really believe postfix can do this.  I just can't seem to make it work.

Postfix is a flexible general-purpose MTA.  It can deliver email
to any not-severely broken destination.

Delivery problem reports are largely useless without logs.  Post logs,
configuration and any bounce text together in a single message.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Christian Kivalo
In reply to this post by jdehnert

> 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 [hidden email]: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:
>
>     /.+/ [hidden email]
>
> 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:[hidden email]  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 | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Igor Golubkov
In reply to this post by jdehnert
I'm using 2.11.6. You could try upgrading but logs would tell us more.

чт, 12 янв. 2017 г. в 3:14, jdehnert <[hidden email]>:
Igor Golubkov wrote
> Only problem I had with office 365 is old postfix version in CentOS 6
> repos. After building newer version all worked as it should.

I'm running this in a Centos 7.2 system, but the Postfix version is a rather
old 2.10.1

Would moving up to Postfix 3.1 help?

I hate breaking the package manager by installing from source, but if 3.1
can resolve my issues I will give it a try.

Can you tell me what mapping you use to change the user in the envelope on
the incoming email?



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

--
mailto:[hidden email]  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-tp87986p88230.html
Sent from the Postfix Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Boris Behrens
Just a short idea,

how about to whitelist the relay server's IP address?
Works for us :-)

best regards
 Boris

Am 12.01.2017 um 09:29 schrieb Igor Golubkov <[hidden email]>:

I'm using 2.11.6. You could try upgrading but logs would tell us more.

чт, 12 янв. 2017 г. в 3:14, jdehnert <[hidden email]>:
Igor Golubkov wrote
> Only problem I had with office 365 is old postfix version in CentOS 6
> repos. After building newer version all worked as it should.

I'm running this in a Centos 7.2 system, but the Postfix version is a rather
old 2.10.1

Would moving up to Postfix 3.1 help?

I hate breaking the package manager by installing from source, but if 3.1
can resolve my issues I will give it a try.

Can you tell me what mapping you use to change the user in the envelope on
the incoming email?



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

--
mailto:[hidden email]  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-tp87986p88230.html
Sent from the Postfix Users mailing list archive at Nabble.com.


smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
Thanks Boris, but I already have a white list for the incoming hosts.  I have a file called 'mynets' that lists all the allowed hosts.  That gets used via the line:

    mynetworks = cidr:/etc/postfix/mynets

in main.cfg

Unfortunately, it does not solve the relay problem.

Boris Behrens wrote
Just a short idea,

how about to whitelist the relay server's IP address?
Works for us :-)

best regards
 Boris
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Richard-2


> Date: Thursday, January 12, 2017 17:28:49 -0700
> From: jdehnert <[hidden email]>
>
> Thanks Boris, but I already have a white list for the incoming
> hosts.  I have a file called 'mynets' that lists all the allowed
> hosts.  That gets used via the line:
>
>     mynetworks = cidr:/etc/postfix/mynets
>
> in main.cfg
>
> Unfortunately, it does not solve the relay problem.
>

As various people have mentioned, without seeing logs and any bounces
that you are getting, it's hard to have a sense of what the issue
might be.


Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
In reply to this post by Christian Kivalo
Thanks for the feedback Christian,

I have been reading the ADDRESS_REWRITING pages in the Postfix web site, but so far everything I try ends up with no mail being passed.

I have tried using sender canonical maps, but I don't think I was configuring it properly because I can't get relayed email to get forwarded.

I have tried using a sender_canonical_map with the contents:

    /.+/ kemail@enphaseenergy.com

I was hopping that that would catch all the incoming mail and rewrite the sender in the message and envelope to kemail@enphaseenergy.com.  It might have done that, but nothing was ever delivered, and I did remember to run my postmap mapname after any edits.

Keep in mind that if I send an email from the mail relay host in the cli, that does get relayed. (I just tested it again, and yup, that is working.)

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

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

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.

--
  Christian Kivalo
I have saved the log info for one of the incoming emails that should get relayed.  Its rather large so I put it on pastebin.

    http://pastebin.com/nE83zdvG

The first process under PID 3027 is the system accepting mail from an internal system.
The second process under PID 4433 is the relay host trying to connect to the exchange server at the office365.com site.

The user kemail@enphaseenergy.com is a valid email user on the office365.com exchanger server, and the account we are trying to use to connect to, authenticate, and send mail from all of the internal hosts and devices.

Just for grins, I also made a pastebin of mail send from the mail relay host that does get delivered.

    http://pastebin.com/wK3mLW12

this helps show that the users connection can, and does work sometimes.
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

Richard-2


> Date: Thursday, January 12, 2017 18:08:05 -0700
> From: jdehnert <[hidden email]>
>
> Thanks for the feedback Christian,
>
> I have been reading the ADDRESS_REWRITING pages in the Postfix web
> site, but so far everything I try ends up with no mail being passed.
>
> I have tried using sender canonical maps, but I don't think I was
> configuring it properly because I can't get relayed email to get
> forwarded.
>
> I have tried using a sender_canonical_map with the contents:
>
>     /.+/ [hidden email]
>
> I was hopping that that would catch all the incoming mail and
> rewrite the sender in the message and envelope to
> [hidden email].  It might have done that, but nothing was
> ever delivered, and I did remember to run my postmap mapname after
> any edits.
>
> Keep in mind that if I send an email from the mail relay host in
> the cli, that does get relayed. (I just tested it again, and yup,
> that is working.)
>
>
> Christian Kivalo wrote
>> Have you read http://www.postfix.org/ADDRESS_REWRITING_README.html
>> ?
>>
>> For better help show logs of one message that passes through your
>> system.
>>
>> 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_client
>> s for  your rewriting of mails from remote hosts to be made.
>>
>> --
>>   Christian Kivalo
>
> I have saved the log info for one of the incoming emails that
> should get relayed.  Its rather large so I put it on pastebin.
>
>     http://pastebin.com/nE83zdvG
>
> The first process under PID 3027 is the system accepting mail from
> an internal system.
> The second process under PID 4433 is the relay host trying to
> connect to the exchange server at the office365.com site.
>
> The user /[hidden email]/ is a valid email user on the
> office365.com exchanger server, and the account we are trying to
> use to connect to, authenticate, and send mail from all of the
> internal hosts and devices.
>
> Just for grins, I also made a pastebin of mail send from the mail
> relay host that does get delivered.
>
>     http://pastebin.com/wK3mLW12
>
> this helps show that the users connection can, and does work
> sometimes.
>
>

Line 232 has:

   smtp.office365.com[40.97.0.2]:587:
     MAIL FROM:<[hidden email]>

which I think is what you're after, but it's followed by the
following in line 245:

   smtp.office365.com[40.97.0.2]:587:
     550 5.7.60 SMTP; Client does not have permissions to send
     as this sender

which might help explain your problem.


Reply | Threaded
Open this post in threaded view
|

Re: Forwarding all mail to office365.com exchange server.

jdehnert
Richard-2 wrote
Line 232 has:

   smtp.office365.com[40.97.0.2]:587:
     MAIL FROM:<[hidden email]>

which I think is what you're after, but it's followed by the
following in line 245:

   smtp.office365.com[40.97.0.2]:587:
     550 5.7.60 SMTP; Client does not have permissions to send
     as this sender

which might help explain your problem.
It might help, but how is it that when I send mail from an account ON the relay host, it has no problem connecting and delivering the mail, with the exact same user?
Thanks, James "Zeke" Dehnert -- mailto:jdehnert@dehnert.com James "Zeke" Dehnert -= Eschew Obfuscation =- "Life is racing. Everything else is just waiting"
12