Aller au contenu

Configuration de SSMTP avec Gandi

·188 mots·1 min

Pour envoyer des mails depuis une application, la solution la plus simple consiste à passer par ssmtp. Cela permet de configurer facilement l’envoi de mails sans se farcir la configuration d’un serveur SMTP complet (postfix, exim, …).

Pour l’installation, on passe par apt, comme d’hab: apt install ssmtp. On modifie ensuite le fichier /etc/ssmtp/ssmtp.conf. La configuration ci-dessous fonctionne pour une adresse hébergée chez Gandi.

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=admin@grimbox.be

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mail.gandi.net:587

# Where will the mail seem to come from?
rewriteDomain=grimbox.be

# The full hostname
hostname=grimbox.be

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

UseSTARTTLS=YES

AuthUser=<smtp_username>
AuthPass=<smtp_password>

Pour tester:

$ mail -s "Test" destinataire@example.org < /dev/null
Null message body; hope thats ok

Vous devriez recevoir le message (relativement) rapidement.