mardi 28 juin 2016

Connecting a postfix to a corporate outlook server


You may wish to test the sending of a mail in an unauthenticated way, but if you are in company working with outlook having some strong security constraints, the relay of unauthenticated mail will be forbidden. Here is a way to transform a postfix server into an unauthencated mail relay. 

You should modify the file /etc/postfix/main.cf and add the following line. 

# This line means mail directed to someone@mydomainname wont be relayed on the other server. 

relay_domains = mydomainname

sender_canonical_classes = envelope_sender, header_sender
# This rewrite rules will make the mail seems like issued by you (always). 
sender_canonical_maps =  regexp:/etc/postfix/sender_canonical_maps

# this Enable postfix to use smtp relay with authentication. 
smtp_sasl_auth_enable = yes
# This is the firsl ine used to initiate the dialog. 

smtp_sasl_mechanism_filter = login ntlm
smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache
# Set your password here 
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

#It is preferable to refrain to your network

smtpd_recipient_restrictions =    permit_mynetworks   reject_unauth_destination   permit

myhostname = toulouse.infosys.com
mydomain = toulouse.infosys.com
relayhost = [my.outlook.corporateserver.com]:587
myorigin = $myhostname

# mydestination = $myhostname, localhost.$mydomain, localhost
# To enable all the interfaces

inet_interfaces = all
mydestination =
mynetworks = 10.161.86.0/24 127.0.0.0/8


The file /etc/postfix/sender_canonical_maps
Contains and rewrite all header so that all mails appear to be issued by my.email@mycompany.com

/.+/    my.email@mycompany.com

File /etc/postfix/sasl_passwd contains 
[my.outlook.corporateserver.com]:587    my.email:My-P4ssw0rD


You should then hash this file
postmap /etc/postfix/sasl_passwd

Restart postfix 


service postfix restart

Dont forget to open firewall on port 25. All the mail you will send to thepostfix server will be relyed to the corporate server with your name.


 

Aucun commentaire: