mardi 16 février 2016

Create a server that relay to a Exchange Server masquerading the username

You want to connect your linux app to your company exchange server, but you server does not allow the unauthenticated mail submission. You can implement it by using a nintermediate mail relay, that will transform your mail so it can be submitted to the mail server.

yum install postfix
You must install SASL.
yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl-ntlm

In the /etc/postfix/main.cf

For having your mail relayed, add the line:

relayhost = [myexchangeserver.mycompany.com]:587
smtp_sasl_mechanism_filter = login ntlm
smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous


In the sasl_password put your password
[myexchangeserver.mycompany.com]:587  myuser:mypassword

Then build the hash for it to be used by postfix.

postmap /etc/postfix/sasl_passwd


For rewriting the mail address:

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


in /etc/postfix/header_checks
/From:.*>/ REPLACE From: My Name

Aucun commentaire: