Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: how to change email sender's name?

Tags:

python

smtp

gmail

The emails which are sent automatically using smtplib via gmail, once are received. Receivers see the sender of the email is my email address. Is there any way to display the sender as a name that i can customize?

like image 803
Zi Wang Avatar asked Nov 01 '25 10:11

Zi Wang


1 Answers

If someone comes around looking for a simpler if maybe not so comprehensive, way I managed to do this very simply on yagmail v0.10.212 with:

yagmail.SMTP({"[email protected]": "Alias"}, "pwd").send(mail, subject, body)

I had it setup to only need the user part of the email address, but I have to use the full address when adding the dict for the alias.

If you are using a .yagmail file then you don't need the password argument as well which improves security. Or have it on a keyring, which is what i do.

yagmail.SMTP({"[email protected]": "Alias"}).send(mail, subject, body)

like image 102
Animismus Avatar answered Nov 04 '25 02:11

Animismus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!