I suggest you do this on a desktop / laptop PC
I will apologise at the start for some bad screen shots , it just because you cant screen cap some pages/popups,
and don't close any tabs until you are done you may need to get back to a page and it simpler if you can use an already open page.
So first thing log in to you pi email account on google from a browser.
then click on the account icon on the top right of the page to get this
Then click on manage your google account
at the home page
you will need to add your date of birth if you have not already done this ( if you don't you may be prevented from continuing on a later page ) and then click on protect your account under you have security recommendations, assuming you have not added a recovery phone number
you may need to click on 2 verification methods to expand the page.
so you can now update email /phone number as required.
once you have done this you can click on the security tab on the left of the screen which will get you here.
from here you can activate 2-step verification to sign in to your account ( click on 2-step verification ), here you will set up sending a text to your mobile when ever you log in to your account as a second security step..
once you have done this you need to go back to the security page, your inbox should still be open in one of the tabs on your browse so just click on the account icon top right and click on manage your google account and then security.
now you can see an option for app passwords, if you click on it you will be taken to this page, to create you app password.
now you need to enter these details, its important you get them right or the app password wont work ( don't ask me how I know )
first click on select app and from the drop down box select Mail.
then click on select device and from the drop down box select other and enter pi in the field.
now click on generate button which will present the code like this.
DO NOT CLOSE THIS BOX until you have copied the code down because once you close this box you cant ever see the code again..
Now to update your pi's ( the easy bit )
so if you are sending mail using python then in your program you need to replace the password entry with the 16 digit app password like this.
Code: Select all
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
email_user = "firstname.lastname@example.org"
email_password = "tgafghizmaeas" <<<<<<<< enter 16 digit code here to replace the password you were using
email_send = "address to send to"
subject = "Test email from pi"
msg = MIMEMultipart()
msg["From"] = email_user
msg["To"] = email_send
msg["Subject"] = subject
body = "Hi there, sending this email from Python!"
text = msg.as_string()
server = smtplib.SMTP("smtp.gmail.com",587)
if you are using msmtp to send mail then you need to edit your msmtprc file in /etc and add the 16 digit code like this
Code: Select all
# Gmail specifics
from a email@example.com
user a firstname.lastname@example.org
password tgafghizmaeas <<<<<<<< enter 16 digit code here to replace the password you were using
account default : gmail
now you pi can continue to send email using google just as it did before, and you can use the same credentials on more than one pi at the same time and email will be sent from them all.
you can add more app passwords if you find the one you created does not work, like I did when I got the mail and pi entries incorrect, but I suggest you delete the old non working one first which you will find the option for on the same page you used to create one , just click on the icon to the right of the listed app passwords.
Of course you will be asked for your account password the one you normally use to sign in many times during these processes so make sure you have it to hand if you can't remember it.
hope this helps you , I have not covered steps like updating recovery email and entering phone number or actually activation 2 step authentication because these steps will be guided by the web page anyway and there is lots of personal information on the pages, just allow yourself an hour or so for each account you want to update and you should be fine, but if you have a specific problem I will try to help.
Trust me it gets easier the more times you do it I have done it for over 15 accounts now , and not just for use on the pi but on PC's using email programs that need this option as well.
Edited to correct typing errors