Table des matières

Envoi de mail automatique avec gmail

E1. Installer le client smtp sSMTP

Par défaut, mail se sert d'exim, un autre system d'envoi de mail. En installant ssmtp avec la ligne de commande suivante, l'utilitaire mail est reconfiguré pour utiliser ssmtp

 sudo apt-get install ssmtp

Suite à l'installation sendmail sera un raccourci pointant sur ssmtp

E2. Configuration de ssmtp

Il faut éditer 2 fichiers : /etc/ssmtp/ssmtp.conf et /etc/ssmtp/revaliases ssmtp.conf contient les paramètres d'authentifcation revaliases permet de définir des handlers “compte unix appelant mail” –> service du client ssmtp à utiliser

Exemple :

 # *************** Config file for sSMTP sendmail *************
 # The person who gets all mail for userids < 1000
 # Make this empty to disable rewriting.
 root=xavier.marquis@gmail.com
 
 # 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=smtp.gmail.com:587
 
 # Login/Passwd
 AuthUser=xavier.marquis@gmail.com
 AuthPass=freeman1979
 
 # Where will the mail seem to come from?
 rewriteDomain=gmail.com
 
 # The full hostname
 # hostname=localhost
 hostname=xms_rbpi2
 
 # 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
 
 UseTTLS=YES
 UseSTARTTLS=YES

E3. Resolution des problemes gmail

It may take more than one step to fix this issue

1. Take the step mentioned earlier. Log into your google email account and then go to this link: https://www.google.com/settings/security/lesssecureapps and set “Access for less secure apps” to ON. Test to see if your issue is resolved. If it isn't resolved, as it wasn't for me, continue to Step #2.

2.Go to https://support.google.com/accounts/answer/6009563 (Titled: “Password incorrect error”). This page says “There are several reasons why you might see a “Password incorrect” error (aka 534-5.7.14) when signing in to Google using third-party apps. In some cases even if you type your password correctly.” This page gives 4 suggestions of things to try.

For me, the first suggestion worked:

Go to https://g.co/allowaccess from a different device you have previously used to access your Google account and follow the instructions. Try signing in again from the blocked app.