Phone numbers with certain carriers aren’t receiving SMS message from my Python code?

262 Views Asked by At

goal: send a SMS message using python.

Google eventually lead to the smtp library and then my code became:

import smtplib
import imaplib
import email

#emailAddress = "[email protected]"
#emailPassword = "appPassword"
#phoneAddress = "[email protected]"
from config import emailAddress, emailPassword, phoneAddress

message = "testing test test"

smtpServer = "smtp.gmail.com"

server = smtplib.SMTP_SSL(smtpServer, 465)
server.ehlo()
server.login(emailAddress, emailPassword)

server.sendmail(emailAddress, phoneAddress, message)

server.quit()

The above code works when I changed the phone address to someone with Bell. When it was Rogers and Fido I could see the sent message on my email account, but the SMS never came. No error pops up in shell either.

Does anyone know why this happens?

1

There are 1 best solutions below

0
Vignesh On

I use Fast2sms. it has some free limit, just go to their website signup and create an authorization code. signup and go to this link to get auth code https://www.fast2sms.com/dashboard/dev-api

They will ask credits for sending sms to DND Numbers

import requests
url = "https://www.fast2sms.com/dev/bulk"
querystring = {"authorization":"Your Code here","sender_id":"FSTSMS","message":"Message content ","language":"english","route":"p","numbers":"8012XXXXX3"}
headers = {
    'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)