help using smtplib to work ..

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Nov 9 00:09:57 CET 2006


At Wednesday 8/11/2006 19:23, NicolasG wrote:

>I'm using the following code to send e-mail through python:
>
>import smtplib
>
>fromaddr = 'myMail at gmail.com'
>toaddrs  = 'myOtherMail at gmail.com'
>subject = 'someting for subject !'
>
>msg = 'This is body of the mail.'
>
>msg = 'From: ' + fromaddr + '\nTo: ' + toaddrs + '\nSubject:' + subject
>+ '\n\n' + msg
>print "Message length is " + repr(len(msg))
>
>server = smtplib.SMTP('smtp.gmail.com')
>server.set_debuglevel(1)
>server.sendmail(fromaddr, toaddrs, msg)
>server.quit()
>
>send: 'mail FROM:<myMail at gmail.com> size=106\r\n'
>reply: '530 5.7.0 Must issue a STARTTLS command first
>s1sm7666914uge\r\n'
>
>What am I doing wrong ?

gmail.com requires authentication before sending mail. Try this 
sequence: ehlo, starttls, ehlo (again!), login, sendmail, quit
(BTW, you need a space after Subject:, and all \n should be \r\n)


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list