smtplib not working as expected
MRAB
python at mrabarnett.plus.com
Fri Dec 26 20:06:51 EST 2014
On 2014-12-27 00:39, Juan Christian wrote:
> I have the following test code:
>
> import smtplib
>
> fromaddr = 'mksfjnsfji4433j43jc at bk.ru <mailto:mksfjnsfji4433j43jc at bk.ru>'
> toaddrs = ['mksfjnsfji4433j43jc at bk.ru <mailto:mksfjnsfji4433j43jc at bk.ru>']
>
> msg = ("From: %s\r\nTo: %s\r\n\r\n"
> % (fromaddr, ", ".join(toaddrs)))
>
> msg = msg + 'test'
>
> print("Message length is " + repr(len(msg)))
>
> server = smtplib.SMTP('smtp.mail.ru <http://smtp.mail.ru>', 465)
> server.set_debuglevel(1)
> server.sendmail(fromaddr, toaddrs, msg)
> server.quit()
>
> And when I execute it, it keeps running forever and I don't get any
> email. What's missing, what's wrong? The smtp server and port are
> correct - https://help.mail.ru/enmail-help/mailer/popsmtp
>
> I'm following this tutorial:https://docs.python.org/3/library/smtplib.html
>
> Python 3.4.2
>
According to the docs, if you let the port parameter default to 0,
it'll use port 465.
I tested with my ISP.
Using port 465, it failed.
Using the default, it succeeded.
More information about the Python-list
mailing list