-
-
Save alexle/1294495 to your computer and use it in GitHub Desktop.
# sms.py | |
# Sends sms message to any cell phone using gmail smtp gateway | |
# Written by Alex Le | |
import smtplib | |
# Use sms gateway provided by mobile carrier: | |
# at&t: [email protected] | |
# t-mobile: [email protected] | |
# verizon: [email protected] | |
# sprint: [email protected] | |
# Establish a secure session with gmail's outgoing SMTP server using your gmail account | |
server = smtplib.SMTP( "smtp.gmail.com", 587 ) | |
server.starttls() | |
server.login( '<gmail_address>', '<gmail_password>' ) | |
# Send text message through SMS gateway of destination number | |
server.sendmail( '<from>', '<number>@tmomail.net', '<msg>' ) |
What's twomail.net? My phone isn't receiving an SMS...
Worked for me to an att number, thanks!
@keeganjk "@tmomail.net" is the domain ("sms gateway") that T-mobile uses for sending sms from email. This is the domain you would use when sending an sms to a T-mobile phone.
Here are some other popular domains you would use for other carriers (ie. Sprint)
- Sprint:@pm.sprint.com
- Verizon:@vtext.com
- AT&T:@mms.att.net
Shoutout to @bturnip for making clear that different carriers have different sms gateways.
Have you guys had any issues with google blocking the sent message?
Hey, I am getting the MSG but, Am getting a black line instead of the MSG.
HI ALL,
import smtplib
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( '[email protected]', 'xxxxxxxxxx' )
server.sendmail( '[email protected]', '[email protected]', 'jjjjjjjjjjjjjjjjj' )
Am getting below error.
Could you please help me.
The response was:
550 permanent failure for one or more recipients ([email protected]:blocked)
Traceback (most recent call last):
File "C:/Users/solo/AppData/Local/Programs/Python/Python37-32/Lib/idlelib/idle_test/caluculator.py", line 4, in
server = smtplib.SMTP( "smtp.gmail.com", 587 )
File "C:\Users\solo\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 251, in init
(code, msg) = self.connect(host, port)
File "C:\Users\solo\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Users\solo\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 307, in _get_socket
self.source_address)
File "C:\Users\solo\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 727, in create_connection
raise err
File "C:\Users\solo\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 716, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
help
Is there anyway to recive data back through the same email
Worked for me! Thank you!
@muthukumarece5 I was getting the same error! This is what fixed it for me.
T-Mobile likes it if it is in an email
type format. Here is the T-Mobile help form (https://support.t-mobile.com/thread/141399)
The following code worked for me
import smtplib
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( '[email protected]', 'xxxxxxxxxx' )
from_mail = '[email protected]'
to = '[email protected]'
body = '<body>'
message = ("From: %s\r\n" % from_mail + "To: %s\r\n" % to + "Subject: %s\r\n" % '' + "\r\n" + body)
server.sendmail(from_mail, to, message)
I tried this method. Google blocked my sign in attempt because the app(smtp, I think) "doesn't meet modern security standards."
Is there a workaround for this?
You have to enable less secure devices in your Google account,
I used this method and It worked great! Is there any way though that I can get the script to respond to a message in the conversation?
For those interested, here is an implementation with multiple carriers + and async support: https://bit.ly/send-txt-msg
Do you guys know how to remove the subject when you send the text? Like the forward slashes? I just get / no subject / when I leave it blank
the above Says that you donot have smptlib module imported for confirmation just do this:
import smtplib
and try compiling or running the code, if you get error then you go to fix that,