Forums

Can's send SMS with SMTPLIB from pythonanywhere

I'm able to send SMS with SMTPLIB from my computer without a problem. Below is the simple script i'm using. The problem is that when I run the script on pythonanywhere I don't receive the text message. The truth is, I don't get any errors either. Is is possible that my phone carrier is blocking the sms for some reason?

import smtplib
email = "email@gmail.com"
password = "1234567890"
connection = smtplib.SMTP("smtp.gmail.com", port=587)
connection.starttls()
connection.login(user=email, password=password)
connection.sendmail(from_addr=my_email, to_addrs="5555555555@vtext.com", msg="Test")
connection.close()

Thanks

It's possible -- or perhaps it's happening on the Gmail side, though normally you'd get an authentication error if that was the case. Have you tried using an application-specific password?

Yes, I am using an application-specific password.

I'm wondering if something about how its being sent through the pythonanywhere server is causing it to be tagged by my carrier as suspicious and therefore its getting blocked. and if so, any suggestions on how to get past that? As I mentioned in my original question, I don't have any problems when I run the script directly from my computer. The thing that i'm confused about is that if it made it through google (hence the reason why i'm not getting any error messages), what could be the problem at that point? Thanks again for your time

If you suspect that your carrier is rejecting the message for some reason, that is something that you would need to ask your carrier about. We have no way of knowing anything about their policies.