Why does smtplib not work with all emails?

import smtplib 
EMAIL = '[email protected]'
PASS_EMAIL = '**********'
email = "[email protected]"
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
smtpObj.starttls()
smtpObj.login(EMAIL, PASS_EMAIL)
smtpObj.sendmail(EMAIL, email, "Hello, a message for testing!")
smtpObj.quit()

If I send it to the mail on gmail, then everything works. With Yandex every other time. mail.ru and rambler does not work - mail does not reach. I.e., if I try to send an email to other email services via gmail, it does not reach them (even in spam). How to fix it?

Author: Victor VosMottor, 2021-01-27

1 answers

There are 2 options for sending via smtp. The first one: you log in to the sender's server, the second one without authorization to the recipient's server.

In the second case, it is better to sign the letter via DKIM, otherwise you will get 50/50 in spam.

In the first case, the mail domain must belong to the server.

For bots, it is better to start a local smtp server and send it to it, and it will send the recipient to the server.

And also Mail.ru requires web authorization

 2
Author: eri, 2021-01-27 11:50:04