configurer_le_serveur_postfix_pour_envoyer_des_mails_depuis_yunohost_ou_gmail

Installer ce qui est nécessaire :
apt install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

Dans /etc/postfix/main.cf :

modifier :

relayhost =
en
relayhost = [smtp.gmail.com]:587

mydestination = $myhostname, jmanson.fr, srv-pve2.jmanson.lan, localhost.jmanson.lan, localhost
en
mydestination = mon@mail.fr

myhostname=srv-pve1.jmanson.lan
en
myhostname=mon.smtp.fr

ajouter :
canonical_maps = hash:/etc/postfix/canonical
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

modifier /etc/aliases :
postmaster: mon@mail.fr
nobody: mon@mail.fr
hostmaster: mon@mail.fr
webmaster: mon@mail.fr
www: mon@mail.fr
root: mon@mail.fr

Créer /etc/postfix/canonical
root@mondomaine.fr mon@mail.fr

créer /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 USERNAME@gmail.com:MDP_mail

lancer les commandes suivantes :
chmod 400 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/canonical
newaliases
cd /etc/ssl/certs
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key-for-smtp-gmail.pem -out cert-for-smtp-gmail.pem
cat /etc/ssl/certs/cert-for-smtp-gmail.pem | tee -a /etc/postfix/cacert.pem
/etc/init.d/postfix restart

tester :
echo “Test mail from postfix” | mail -s “Test Postfix” adresse@mail.com

sources :
https://www.it-connect.fr/configurer-postfix-pour-envoyer-des-mails-avec-gmail/
https://forum.ubuntu-fr.org/viewtopic.php?id=1047711

  • configurer_le_serveur_postfix_pour_envoyer_des_mails_depuis_yunohost_ou_gmail.txt
  • Dernière modification : 2023/02/01 12:26
  • de jeremy