Answer the question
In order to leave comments, you need to log in
How to send email from mail.ru in Python?
Here is such a script that perfectly sends a letter from gmail to mail.ru, if in the Gmail settings you allow access to mail to unverified applications.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
fromaddr = "[email protected]"
toaddr = "[email protected]"
mypass = "password"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "Привет от питона"
body = "Это пробное сообщение"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, mypass)
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
Answer the question
In order to leave comments, you need to log in
Already, I think, irrelevant, but still I will answer:
replace
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server = smtplib.SMTP_SSL('smtp.mail.ru', 465)
Try changing the port to 465.
This port is listed on the official mail.ru website:
https://help.mail.ru/mail-help/mailer/popsmtp
fromaddr = "[email protected]"
toaddr = "[email protected]"
It is difficult to make friends with Mail.ru and python, it is better to use gmail
solkogan.ru
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question