![]() ndmail(emailAddress, to_number, message)Ī quick note to Gmail users who have enabled 2-factor authentication: you will need to create an application-specific password. Whenever we talk about sending an SMS to our phone using any programming language the first thing that comes into our head is Twilio SMS library.But in this post we are going to avoid twilio and use python builtin module SMTPLIB I know it sounds crazy since SMTPLIB is used to send emails but we can also send. # Send text message through SMS gateway of destination number #the destination phone number formatted as an email address, according to the carrier's format Install dependencies You can install the Plivo SDK using pip: 1 pip install plivo Initialize the dependencies Create a file named send-sms.py and add the following code to it. private static readonly string message 'This message was sent through Amazon Pinpoint' + 'using the AWS SDK for. private static readonly string destinationNumber '+14255550142' // The content of the SMS message. MailServerPort (int, optional): The port of the SMTP server to use. Tutorial: How to Send SMS Using a Plivo SMS API You need a Plivo account and an SMS-enabled phone number to get started. For best results, you should specify the // phone number in E.164 format. Mailserver (str, optional): The SMTP server to use. Supported carriers are 'att', 'tmobile', 'verizon', 'sprint'. Gmail will require you to make an app-specific password.Ĭarrier (str, optional): The carrier of the phone number. Format is '000-000-000'ĮmailAddress (str): the email address the message will be sent from over SMTPĮmailPW (str): The password to the email address. """Sends a text message to the specified phone number, using the provided settings 'att': SendText(message, phoneNumber, emailAddress, emailPW, carrier = 'tmobile', mailserver = "", mailServerPort = 587): ![]() I extended the method from reddit to be more flexible, and support T-Mobile's message constraint. ![]() Google was of limited helpfulness, but I combed a bunch of support forums and discovered that T-Mobile requires the message body to be formatted in the basic SMTP email format, or it will reject the message as spam. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |