I have a program of mine I've been using for over a year which involves the some sending of emails (or texts, via the email address method, eg. 1234567890@vzwpix.com). Here's some code for one of the methods, sending emails via Yahoo's STMP server (you have to go under your profile in Yahoo and get that code to use with an app - easy enough):
conn = smtplib.SMTP_SSL('smtp.mail.yahoo.com', 465,timeout=5)
conn.ehlo()
conn.login(email_address, passcode)
conn.sendmail(email_address, rEmail_address, Subject + message)
conn.quit()
Fairly straightforward. The frustration is that I am continually struggling to have it be reliable. For example, while this Yahoo method often works well, occasionally I get an error like it unexpectedly quit. And then after a couple weeks or so, Yahoo suddenly decides my account is being attacked and it quits working completely until I go in and get a new app passcode. Gmail seemed a bit more reliable but did the same sort of thing, thinking it was under attack and switching off the "Allow less secure apps" setting, and nothing works suddenly until I go fight with it and turn it on again. I tried using Google's API to send emails, but this went bad after a while, too. I don't have the security issue, but again at random intervals, my secret token doesn't work (token has expired or been revoked), and I have to delete the token file, and have the web page open up so I can authorize it all over again. And at some point, this method just stopped sending any of my emails to text addresses. This is when I tried Yahoo thinking it would be more easy going. Nah. I would love to hear from you folks who are sending emails that aren't breaking down over and over. What am I doing wrong? What's the best way to go about this so they just work and I can stop fighting with it? Thanks so much!