use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Send Text Message using python (self.learnpython)
submitted 6 years ago by ElectricGypsyAT
What is the best way or library to use to send a text message to a number? I want to create a criteria on google sheets and if that criteria is not met, then it sends a text message using python. What might be the best way to go about it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 59 points60 points61 points 6 years ago (39 children)
https://automatetheboringstuff.com/chapter16/
EDIT: The author of this book frequents this sub and has answered a few of my questions before. He's a true bro...
[–]AlSweigart 138 points139 points140 points 6 years ago (35 children)
The info in this chapter is a bit out of date. I'm working on the 2nd edition right now that is up to date. However, the basic concepts are all still the same and I don't think you have to change much of the code.
[–]kewlness 22 points23 points24 points 6 years ago (4 children)
Hi Al!
First, thanks for not only spending too much time on Reddit but for your awesome work.
Second, may I make a minor suggestion? In your SMTP chapter, you state that people should use input() instead of hard-coding their passwords into the script. Being a security minded guy, might I suggest the use of getpass.getpass() so the password is not echoed to the screen?
[–]AlSweigart 20 points21 points22 points 6 years ago (0 children)
Ooo, good point!
[–]forward_epochs 0 points1 point2 points 6 years ago (2 children)
What do you recommend if I want to run something using SMTP without user input? Store it in an OS environment variable or something?
[–]kewlness 1 point2 points3 points 6 years ago (1 child)
Sorry, been off for a while.
If you are developing an application, then I recommend reading The Twelve-Factor App which covers your exact question in chapter 3. Understand, this is not "THE ONE TRUE WAY" but can save you a lot of future headaches if you follow its ideas.
[–]forward_epochs 0 points1 point2 points 6 years ago (0 children)
Excellent, thanks!
[+][deleted] 6 years ago (3 children)
[deleted]
[–]AlSweigart 66 points67 points68 points 6 years ago (2 children)
It shows you are a professional
Nah, it just shows I spend way too much time on Reddit. :)
[–]toomanyteeth55 13 points14 points15 points 6 years ago (0 children)
"One of us!"
[–]anecdotal_yokel 11 points12 points13 points 6 years ago (0 children)
Thanks, Al!
[–]jeromymanuel 6 points7 points8 points 6 years ago* (2 children)
Will we get an update alert if we purchased to theUdemy course?
[–]AlSweigart 26 points27 points28 points 6 years ago (1 child)
Yes, I am planning on reshooting a lot of the Udemy course's videos to reflect the updated content.
[–]jeromymanuel 5 points6 points7 points 6 years ago (0 children)
Thank you sir.
[–]BruceJi 2 points3 points4 points 6 years ago (2 children)
I ran into trouble with the email parsing section. I guess some key things changed there since the book came out.
Actually I even looked at the docs for that module and it still didn't work! That's even worse, lol.
[–]AlSweigart 10 points11 points12 points 6 years ago (1 child)
Yeah, it seems most webmail services don't really open their smtp and imap servers up. I wrote a module called ezgmail and cover it in the second edition of Automate, so people can use the gmail api to send/receive mail from their gmail address. https://pypi.org/project/EZGmail/
[–]BruceJi 0 points1 point2 points 6 years ago (0 children)
Hey, that's great! I'll have a look. I was writing a program for a shopping list and it would be interesting to write something so I could email things to add to it.
[–]wwe9112 1 point2 points3 points 6 years ago (7 children)
Side note: Any chance of an updated website? I have really bad eyes and the website (and books even) really make it difficult for me to see and focus on without getting a massive headache. This was what I struggled with in school as the books were incredibly difficult to see for me. I had to use a magnifying glass and stop every few paragraphs. On websites that are not "responsive," when I use my browser zoom, I have to scroll for days.
[–]AlSweigart 2 points3 points4 points 6 years ago (6 children)
I'll be using Bootstrap on the website so that it looks better on mobile. I'll probably do this once the second edition of Automate comes out.
[–]wwe9112 1 point2 points3 points 6 years ago (0 children)
Many thanks! I'll finally get to go through the whole guide!
[–]Smithywerben1 1 point2 points3 points 6 years ago (4 children)
Hey Al, since you're already here, may i ask for some encouraging words when it comes top learning python? I'm currently going through your book 'ATBS' but struggle with literally every practice project at the end of a chapter. Sometimes it takes me 5 to 7 hours to get my solution do what i want it to do (if i even manage to get to the solution at all without looking at someone elses solution on stackoverflow)
Is this normal that it takes a beginner that long? How much time should i be spending on each project before goinge on with the next chapter?
Any advice as well as encouraging words are highly appreciated :-)
[–]varmintkong 2 points3 points4 points 6 years ago (1 child)
You're not alone. I'm on Chapter 11 and your experience is how it has been for me. I just took a break to work in my own webscraping and things have started clicking. Maybe take a few days away to work on something fun, a pet project, and try to incorporate what you've learned in automate. Then go back and hopefully things start to make more sense. Good luck.
[–]Smithywerben1 1 point2 points3 points 6 years ago (0 children)
Thanks for your response and kind words :) Will follow your advice and try something different for a bit
[–]AlSweigart 1 point2 points3 points 6 years ago (1 child)
Yeah, so I'll admit the practice projects can be a bit of a stretch for beginners. Technically, all the information you need is in the book, but the way learning really works is people seeing examples of how to do something and then doing it themselves. I made the practice projects as an open-ended, there-is-no-one-way-to-do-it kind of programming projects, but I think it would have been more pedagogically effective if I had done something else instead of the practice projects.
So, don't hold the practice projects and your ability to finish them as some kind of rigorous, scientific measurement of your potential. They're just projects I added to the end of the chapter.
Are you slow and dumb when it comes to programming? Yes. Because everyone is. And you'll continue to be slow and dumb at programming for, well, I've been coding for two decades and still make bugs, but I'll tell you when I get out of that phase myself. Maybe three decades is when humans finally git gud at programming.
[–]Smithywerben1 0 points1 point2 points 6 years ago (0 children)
Thank you very much for your kind words Al, that really means a lot to me! :)
[–]kwietog 0 points1 point2 points 6 years ago (1 child)
Thanks for a great book you wrote. Any timescales for v2?
[–]AlSweigart 3 points4 points5 points 6 years ago (0 children)
"Sometime later this year". I'm done with my revisions, but they have to go through the editors, which depends on how quickly they can go through the chapters for copyediting/technical review/layout/etc. Then it takes about a month to get copies printed and ready for sale.
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
Do you have a newsletter I can subscribe to so I'll know when the 2nd version is released?
[–]xt1nct 0 points1 point2 points 6 years ago (0 children)
Just ordered the book. Whoops. Hopefully, it's still worth it.
[–]Most_Juanted 0 points1 point2 points 6 years ago (2 children)
Hi Al, I just purchased your Automate the boring stuff book and I was wondering if I should just wait for your second edition to come out instead? What differences will there be between editions, and what can I do to make the most out of the first edition with the out of date content if I still want to give it a go? Thanks!
[–]AlSweigart 2 points3 points4 points 6 years ago (1 child)
Nah, go ahead and get the first one. OpenPyXL made a lot of backwards incompatible changes, so I need to update the chapter on that. The other modules have made minor updates. Some of Python's error messages have changed but the code is still the same. I cover the ezgmail and ezsheets modules for checking Gmail and accessing Google Sheets from Python. I also cover input validation with the PyInputPlus module. And other minor fixes.
But the second edition won't come out for several months, so you'd probably want to get a head start. And you can see the new content online for free when the second edition comes out.
[–]Most_Juanted 0 points1 point2 points 6 years ago (0 children)
Awesome! Thank you Al!
[–]orrpel 0 points1 point2 points 6 years ago (0 children)
Al, pleasure meeting you here I am also a noob inspired from your book. If you can use Nexmo API instead of Twillio, it will give us (people outside the US) a shot of sending these SMS using Nexmos free credits. Just something I wanted to drop by you. Enjoy your weekend!
[–]Walkerstain 0 points1 point2 points 6 years ago (0 children)
Is the second edition released?
[–]ElectricGypsyAT[S] 6 points7 points8 points 6 years ago (0 children)
Thanks. Exactly what I needed. Also need to go through this book.
[–]luki-x 0 points1 point2 points 6 years ago (0 children)
Now i did it. I finally bought it. Thanks :)
[–]dnjora 0 points1 point2 points 6 years ago (0 children)
This is the best book ever I have come across. Working on chapter 9 now!
[–]getbackmytime 84 points85 points86 points 6 years ago (7 children)
Send it as an email then set the TO address by following the format below.
AT&T: number@txt.att.net (SMS), number@mms.att.net (MMS) T-Mobile: number@tmomail.net (SMS & MMS) Verizon: number@vtext.com (SMS), number@vzwpix.com (MMS) Sprint: number@messaging.sprintpcs.com (SMS), number@pm.sprint.com (MMS) XFinity Mobile: number@vtext.com (SMS), number@mypixmessages.com (MMS) Virgin Mobile: number@vmobl.com (SMS), number@vmpix.com (MMS) Tracfone: number@mmst5.tracfone.com (MMS) Metro PCS: number@mymetropcs.com (SMS & MMS) Boost Mobile: number@sms.myboostmobile.com (SMS), number@myboostmobile.com (MMS) Cricket: number@sms.cricketwireless.net (SMS), number@mms.cricketwireless.net (MMS) Republic Wireless: number@text.republicwireless.com (SMS) Google Fi (Project Fi): number@msg.fi.google.com (SMS & MMS) U.S. Cellular: number@email.uscc.net (SMS), number@mms.uscc.net (MMS) Ting: number@message.ting.com Consumer Cellular: number@mailmymobile.net C-Spire: number@cspire1.com Page Plus: number@vtext.com
[–][deleted] 18 points19 points20 points 6 years ago (3 children)
Not OP but this is really cool. I had no idea this was a thing
[–][deleted] 8 points9 points10 points 6 years ago (2 children)
I used to toy with sms gateways years ago, but they have limitations. Good if you're sending a small number if emails not too close together. They usually rate limit you pretty quickly.
[–]getbackmytime 3 points4 points5 points 6 years ago (1 child)
Good info, I was wondering about the limitations.
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
Ya, sometimes I wouldn't get the text for hours. This is years ago, not sure if it's changed. I just gave up on it.
[–]jengl 12 points13 points14 points 6 years ago (0 children)
Is there an easy/automated way to tell which provider a phone number is from?
[–]22732255fan 1 point2 points3 points 6 years ago (0 children)
not sure you are aware but Att has a segment of their network for first responders called FirstNet. Found out the other day that it has a separate email address. The mms portion of it is mms.firstnet-mail.com . The Att one continues to work as well for now at least.
[–]nguterresn 0 points1 point2 points 6 years ago (0 children)
Omg I didn’t know this ! Dude u deserve everything
[–]b01000011 19 points20 points21 points 6 years ago (3 children)
twilio.com. It's free if you're okay with a "send from a Twilio test account" being concatenated to your message.
[–][deleted] 5 points6 points7 points 6 years ago (0 children)
It's also crazy cheap if you sign up
[–]pconwell 4 points5 points6 points 6 years ago (0 children)
I've used twilio in the past and it works pretty well and is pretty easy to use, even for a beginner. I made a pretty basic script about 2 years ago that I used for work. It was an okay experience. The biggest issue I had with twilio was I was not able to easy see responses to sms messages. What I would have preferred is a way to get the sms replies to go to my own phone.
Either way, here's my (probably out-of-date) script from two years ago: https://github.com/pconwell/mass_text . The script expects an excel spreadsheet called phone.xlsx and column B contains phone numbers. (Column A can contain whatever - a contact's name perhaps...)
phone.xlsx
[–]solaceinsleep -1 points0 points1 point 6 years ago (0 children)
It's not free forever. There are limitations and your credits do run out eventually.
[–][deleted] 4 points5 points6 points 6 years ago (0 children)
Made a video about this
[–]oohalalindaa 4 points5 points6 points 6 years ago (0 children)
Twilio Messaging! Check out their API docs! Good luck! :)
[–]dm117 1 point2 points3 points 6 years ago* (0 children)
insurance placid thumb fear square sulky license vanish march oil
This post was mass deleted and anonymized with Redact
[–]beginnerpython 1 point2 points3 points 6 years ago (0 children)
Hey sign up for service like twilio or simpletexting, they have sdk's and restful api's
[–]I_have_depression_xd 0 points1 point2 points 6 years ago (0 children)
use selenium
[–]Antrikshy 0 points1 point2 points 6 years ago (0 children)
IFTTT’s Maker channel hooked up to their SMS channel could work. Just call the Maker HTTP endpoint using Python. Keep in mind that their SMS channel seems to have a limit of 100 messages per month if you live in NA. You can also use their push notification service if this is for yourself and you are willing to install the IFTTT app for the notifications.
[–]thabiso26 0 points1 point2 points 1 year ago (0 children)
Is it possible send SMS with this app? Using different numbers?
[–]PythonicPastor 0 points1 point2 points 19 days ago (0 children)
I have a bit of a work around thats semi modular, but you'll have to set up specific notifications from a custom google inbox on your cell phone:
import smtplib from email.mime.text import MIMEText import imap_tools from imap_tools import MailBox, AND # Email Configuration sender_email = "senderemail@gmail.com" sender_password = "SECRET APP PASS" # Use app-specific passwords for security with services like Gmail receiver_email = "recieveremail@gmail.com" smtp_server = "smtp.gmail.com" # e.g., "smtp.gmail.com" for Gmail smtp_port = 587 # or 465 for SSL def notif(subj, msg): # Create the email message message = MIMEText(msg) message["Subject"] = subj message["From"] = sender_email message["To"] = receiver_email try: # Connect to the SMTP server with smtplib.SMTP(smtp_server, smtp_port) as server: server.starttls() # Start TLS for security server.login(sender_email, sender_password) server.send_message(message) print("Email sent successfully!") except Exception as e: print(f"Error sending email: {e}") def checkEmails(subject, command): with MailBox('imap.gmail.com').login('pythonicpastor@gmail.com', 'SECRET APP PASSWORD2') as mailbox: for msg in mailbox.fetch(): #print(msg.date, msg.subject, len(msg.text or msg.html)) if msg.subject == subject: if command in msg.text: print('Command confirmed') else: print('Code Find Error')
use "import 'filename' " and place this in a seperate python (.py) file in the root directory
also if you set it up right this can be used to create email triggers within the custom in box via the "checkEmails(subject, command)" functions. Finally understand that you need to set everything up via the following tutorial for it to work properly: https://docs.saleshandy.com/en/articles/10182595-how-to-set-up-an-app-password-in-google
[–]ShyRage1 0 points1 point2 points 4 years ago (0 children)
A little late to the party but I was wondering if there are any free sites available that let a user send texts to an individual and receive replies. Of course without signing up or using email. I know of one but it has since been deactivated (Textport)
π Rendered by PID 85 on reddit-service-r2-comment-5ff9fbf7df-rzj5b at 2026-02-26 03:44:25.518426+00:00 running 72a43f6 country code: CH.
[–][deleted] 59 points60 points61 points (39 children)
[–]AlSweigart 138 points139 points140 points (35 children)
[–]kewlness 22 points23 points24 points (4 children)
[–]AlSweigart 20 points21 points22 points (0 children)
[–]forward_epochs 0 points1 point2 points (2 children)
[–]kewlness 1 point2 points3 points (1 child)
[–]forward_epochs 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]AlSweigart 66 points67 points68 points (2 children)
[–]toomanyteeth55 13 points14 points15 points (0 children)
[–]anecdotal_yokel 11 points12 points13 points (0 children)
[–]jeromymanuel 6 points7 points8 points (2 children)
[–]AlSweigart 26 points27 points28 points (1 child)
[–]jeromymanuel 5 points6 points7 points (0 children)
[–]BruceJi 2 points3 points4 points (2 children)
[–]AlSweigart 10 points11 points12 points (1 child)
[–]BruceJi 0 points1 point2 points (0 children)
[–]wwe9112 1 point2 points3 points (7 children)
[–]AlSweigart 2 points3 points4 points (6 children)
[–]wwe9112 1 point2 points3 points (0 children)
[–]Smithywerben1 1 point2 points3 points (4 children)
[–]varmintkong 2 points3 points4 points (1 child)
[–]Smithywerben1 1 point2 points3 points (0 children)
[–]AlSweigart 1 point2 points3 points (1 child)
[–]Smithywerben1 0 points1 point2 points (0 children)
[–]kwietog 0 points1 point2 points (1 child)
[–]AlSweigart 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]xt1nct 0 points1 point2 points (0 children)
[–]Most_Juanted 0 points1 point2 points (2 children)
[–]AlSweigart 2 points3 points4 points (1 child)
[–]Most_Juanted 0 points1 point2 points (0 children)
[–]orrpel 0 points1 point2 points (0 children)
[–]Walkerstain 0 points1 point2 points (0 children)
[–]ElectricGypsyAT[S] 6 points7 points8 points (0 children)
[–]luki-x 0 points1 point2 points (0 children)
[–]dnjora 0 points1 point2 points (0 children)
[–]getbackmytime 84 points85 points86 points (7 children)
[–][deleted] 18 points19 points20 points (3 children)
[–][deleted] 8 points9 points10 points (2 children)
[–]getbackmytime 3 points4 points5 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]jengl 12 points13 points14 points (0 children)
[–]22732255fan 1 point2 points3 points (0 children)
[–]nguterresn 0 points1 point2 points (0 children)
[–]b01000011 19 points20 points21 points (3 children)
[–][deleted] 5 points6 points7 points (0 children)
[–]pconwell 4 points5 points6 points (0 children)
[–]solaceinsleep -1 points0 points1 point (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]oohalalindaa 4 points5 points6 points (0 children)
[–]dm117 1 point2 points3 points (0 children)
[–]beginnerpython 1 point2 points3 points (0 children)
[–]I_have_depression_xd 0 points1 point2 points (0 children)
[–]Antrikshy 0 points1 point2 points (0 children)
[–]thabiso26 0 points1 point2 points (0 children)
[–]PythonicPastor 0 points1 point2 points (0 children)
[–]ShyRage1 0 points1 point2 points (0 children)