Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending a text from Python
#1
My cell phone is on the U.S. carrier Verizon - and I can send a text to myself by emailing [email protected], where the letters are the placeholder is my phone number.

I am trying to create a python script that upon execution will send a text to my number. My script is below, with sample instead of my real info:

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

message = MIMEMultipart()
message["From"] = "[email protected]"
message["To"] = "[email protected]"
message["Subject"] = "Python Script Completion"
message.attach(MIMEText("test test", "plain"))

try:
    # Create a secure SSL context
    server = smtplib.SMTP("test.com", 587)
    server.starttls()  # Secure the connection
    server.login(message["From"], "PASSWORD")
    # Send the email
    server.sendmail(message["From"], message["To"], message.as_string())
    print("Completion email sent to", message["To"])
except Exception as e:
    # Print any error messages to stdout
    print(e)
finally:
    server.quit()
My webserver setup is a standard cpanel webserver running on linux. I have email services running there like normal.

My script also works to send email, I can get it without issue.

However, when I sent to @vtext.com from the python script, it never makes it. Now, if I login to webmail with the same email as in the python script and send to @vtext.com, the text goes through. But not python.

I suspect it's probably some anti-spam stuff in the email headers. The webmail interface is likely sending that to @vtext.com, but the python script is not. Any ideas to what the solution may be?
Reply
#2
Yes, this is definitely some sort of anti-spam thing. I got bounceback emails in my mailbox that the email was blocked. But it didn't offer clues how to fix...
Reply
#3
Turns out I was missing a message ID header - I added that in and it's going through now!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending Whatsapp Message in the text file ebincharles869 9 3,703 Jun-21-2022, 04:26 PM
Last Post: snippsat
  Sending string commands from Python to a bluetooth device Rovelin 13 9,759 Aug-31-2021, 06:40 PM
Last Post: deanhystad
  Sending Out Email via Python JoeDainton123 1 4,830 Aug-31-2020, 12:54 AM
Last Post: nilamo
  Python sockets : Client sending to the server nico31780 0 2,383 May-17-2020, 07:56 PM
Last Post: nico31780
  problems sending BIN file with XMODEM python shaya2103 0 2,881 Nov-23-2019, 10:27 AM
Last Post: shaya2103
  Mail sending Python - What it's wrong? airwawekz 1 2,739 Jan-30-2019, 03:20 PM
Last Post: gontajones
  Python, sending E-mails Daxanius 1 2,863 Sep-05-2018, 03:49 PM
Last Post: buran
  Problem in sending email using python nhoh007 1 2,572 Aug-25-2018, 07:20 PM
Last Post: typic
  Sending different color codes in python at certain times Kimzer 4 3,466 Jun-18-2018, 06:56 PM
Last Post: gontajones
  Problem with sending text file as an attachment using this Gmail OAuth script downloaderfan 6 7,048 Feb-07-2018, 09:54 PM
Last Post: downloaderfan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020