Affichage des articles dont le libellé est postfix. Afficher tous les articles
Affichage des articles dont le libellé est postfix. Afficher tous les articles

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.


 

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

jeudi 13 mars 2008

Installer posfix Mandriva avec un relay smtp authentifié

Dans la fichier /etc/postfix/main.cf

Ajouter les lignes :

smtpd_sasl_path = /etc/postfix/sasl:/usr/lib/sasl2
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
relayhost = smtp.my.network
smtp_sasl_security_options =



Créer le fichier /etc/postfix/sasl_passwd et ajouter les lignes

smtp.my.network monuser:monpassword



Redémarrer postfix