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()
This code works with gmail perfectly. However, it doesn't always work with yandex (sometimes I don't receive the email) and it doesn't work with mail.ru and rambler.ru at all. How can I fix it?
dig output:
; <<>> DiG 9.16.8-Debian <<>> gmail.com txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45942
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADDITIONAL: 9
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;gmail.com. IN TXT
;; ANSWER SECTION:
gmail.com. 114 IN TXT "globalsign-smime-dv=CDYX+XFHUw2wml6/Gb8+59BsH31KzUr6c1l2BPvqKX8="
gmail.com. 114 IN TXT "v=spf1 redirect=_spf.google.com"
;; AUTHORITY SECTION:
gmail.com. 138453 IN NS ns4.google.com.
gmail.com. 138453 IN NS ns1.google.com.
gmail.com. 138453 IN NS ns3.google.com.
gmail.com. 138453 IN NS ns2.google.com.
;; ADDITIONAL SECTION:
ns2.google.com. 311240 IN A 216.239.34.10
ns2.google.com. 311240 IN AAAA 2001:4860:4802:34::a
ns1.google.com. 311240 IN A 216.239.32.10
ns1.google.com. 311240 IN AAAA 2001:4860:4802:32::a
ns3.google.com. 311248 IN A 216.239.36.10
ns3.google.com. 311248 IN AAAA 2001:4860:4802:36::a
ns4.google.com. 311248 IN A 216.239.38.10
ns4.google.com. 311248 IN AAAA 2001:4860:4802:38::a
;; Query time: 12 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Ср янв 27 21:52:15 +05 2021
;; MSG SIZE rcvd: 414
question from:
https://stackoverflow.com/questions/65923293/why-does-smtplib-not-work-with-all-email-services 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…