[Tutor] sender name in smtplib

David david at abbottdavid.com
Tue Apr 14 01:04:48 CEST 2009


George Wahid wrote:
> I want to send an email from a google mail account so that the sender
> name will be 'User Name' instead of 'username at gmail.com' in the inbox.
> this is the code I use:         (I'm using python 2.5)
>>>> import smtplib
>>>> g=smtplib.SMTP('smtp.googlemail.com')
>>>> g.ehlo();g.starttls();g.ehlo()
>>>> g.login('username at gmail.com','somepassword')
>>>> g.sendmail('User Name','username at gmail.com','From: User Name\r\nTo: username at gmail.com\r\nSubject: how r u ?\r\nfoobar')
> {}
>>>> g.quit()
> 
> but this doesn't work, what should I do ?

Here is how I do it, may help;
http://dwabbott.com/code/index14.html

-- 
Powered by Gentoo GNU/Linux
http://linuxcrazy.com


More information about the Tutor mailing list