Article View: es.comp.os.linux.programacion
Article #6014Problema con la libreria smtplib de python
From: Xaime
Date: Sun, 24 Aug 2003 01:15
Date: Sun, 24 Aug 2003 01:15
102 lines
4317 bytes
4317 bytes
Hola
Estoy empezando con python y en el tema sobre manejo de cadenas aparece un
ejemplo usando la librer�a smtplib. Empez� a babear y sin poderlo evitar me
puse a jugar con ella.
Cuando lo utilizo con la cuenta de yahoo funciona bien; pero cuando intento
usar la cuenta de telefonica, me da un mensaje de 'Invalid login'.
Obviamente, he comprobado varias veces que usuario y contrase�a fueran
correctos.
Tal vez sea un problema de autentificaci�n. Utilizo Kmail y para el metodo
de autentificaci�n (Preferencias/configurar/cuenta) usa login (no vale
plain). Prob� a�adiendo una l�nea
servidor.doccmd ('AUTH=' 'LOGIN')
pero no funcion�.
El programa es el siguiente:
from smtplib import SMTP
remitente = 'remitente@telefonica.net'
destinatario = 'destinatario@telefonica.net'
mensaje = 'From: %s\nTo: %s\n' % (remitente,destinatario)
mensaje += 'Subject: Un saludo\n\n'
mensaje +='Hola.\n'
servidor = SMTP('smtp.correo.yahoo.es')
servidor.set_debuglevel(1)
servidor.login ('usuario','contrase�a')
servidor.sendmail (remitente,destinatario,mensaje)
servidor.quit()
La salida cuando utilizo el servidor de yahoo es la siguiente:
send: 'ehlo linux.local\r\n'
reply: '250-smtp013.mail.yahoo.com\r\n'
reply: '250-AUTH LOGIN PLAIN\r\n'
reply: '250-PIPELINING\r\n'
reply: '250 8BITMIME\r\n'
reply: retcode (250); Msg: smtp013.mail.yahoo.com
AUTH LOGIN PLAIN
PIPELINING
8BITMIME
send: 'AUTH PLAIN eGFpbWWltZV9nAGNhc2lvcGVh\r\n'
reply: '235 ok, go ahead (#2.0.0)\r\n'
reply: retcode (235); Msg: ok, go ahead (#2.0.0)
send: 'mail FROM:<jardindeletras@telefonica.net>\r\n'
reply: '250 ok\r\n'
reply: retcode (250); Msg: ok
send: 'rcpt TO:<jardindeletras@telefonica.net>\r\n'
reply: '250 ok\r\n'
reply: retcode (250); Msg: ok
send: 'data\r\n'
reply: '354 go ahead\r\n'
reply: retcode (354); Msg: go ahead
data: (354, 'go ahead')
send: 'From: jardindeletras@telefonica.net\r\nTo:
jardindeletras@telefonica.net\r\nSubject: muchisimas
gracias\r\n\r\nHola:\r\nHasta luego.\r\n.\r\n'
reply: '250 ok 1061685274 qp 62131\r\n'
reply: retcode (250); Msg: ok 1061685274 qp 62131
data: (250, 'ok 1061685274 qp 62131')
send: 'quit\r\n'
reply: '221 smtp013.mail.yahoo.com\r\n'
reply: retcode (221); Msg: smtp013.mail.yahoo.com
La salida con el servidor de telef�nica es esta otra:
send: 'ehlo linux.local\r\n'
reply: '250-tnetsmtp1.mail.isp\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-ETRN\r\n'
reply: '250-DSN\r\n'
reply: '250-SIZE\r\n'
reply: '250-AUTH PLAIN LOGIN\r\n'
reply: '250 AUTH=LOGIN\r\n'
reply: retcode (250); Msg: tnetsmtp1.mail.isp
PIPELINING
ETRN
DSN
SIZE
AUTH PLAIN LOGIN
AUTH=LOGIN
send: 'AUTH PLAIN amFyZGluZGVsZXRyYXMkvbmljYS5uZXQAY2FzaW9wZWE=\r\n'
reply: '501 Invalid Login\r\n'
reply: retcode (501); Msg: Invalid Login
Traceback (most recent call last):
File "mail.py", line 23, in ?
servidor.login ('usuario','contrase�a')
File "/usr/lib/python2.2/smtplib.py", line 577, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (501, 'Invalid Login')
En fin, que si has llegado hasta aqu� muchas gracias. Si ayer me llegan a
decir que es tan f�cil escribir un programa para mandar e-mails, pensar�a
que me tomaban el pelo. Fantastico el python.
Gracias de nuevo y un saludo.
Technical Details
Message-ID:
<bi93it$7154u$1@ID-174005.news.uni-berlin.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!241.red-80-34-252.pooles.rima-tde.NET!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,b5026794bc149532,start X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2003-08-23 18:15:11 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!241.red-80-34-252.pooles.rima-tde.NET!not-for-mail From: Xaime <xaime@hotmail.com> Newsgroups: es.comp.os.linux.programacion Subject: Problema con la libreria smtplib de python Date: Sun, 24 Aug 2003 03:15:08 +0200 Lines: 102 Message-ID: <bi93it$7154u$1@ID-174005.news.uni-berlin.de> NNTP-Posting-Host: 241.red-80-34-252.pooles.rima-tde.net (80.34.252.241) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Trace: news.uni-berlin.de 1061687709 7378078 80.34.252.241 (16 [174005]) User-Agent: KNode/0.7.2