Can't figure out smtp in python. Examples do not really help. I try to send emails through my smtp server
2 answers
Dmitry wrote all the buzz, but if through his smtp-server, then in the line
s = smtplib.SMTP(smtp_server)
The smtp_server variable is simply not necessary. thus, the string acquires the form -
s = smtplib.SMTP()
then add a string
s.connect()
and all! is ready! you can check.
|
Here is an example of sending a letter
import smtplib from email.mime.text import MIMEText me = 'admin@mail.ru' you = 'kot_smit@mail.ru' smtp_server = 'smtp.mail.ru' msg = MIMEText('Message e-mail') msg['Subject'] = 'The contents of ' msg['From'] = me msg['To'] = you s = smtplib.SMTP(smtp_server) s.sendmail(me, [you], msg.as_string()) s.quit()
|