admin管理员组

文章数量:1335107

I wrote the following code to send a text message from my python script. The first time I ran it I successfully received a text message to my phone, but it was blank (no message). I re-ran the code 3 times and now get no message, however I noticed the messages are in the outbox of the email (though the recipient phone number is in BCC instead of recipient). I also attempted sending the message straight from email instead of from the python script and no message arrived.

Can you please offer me ideas to try to debug why the code malfunctioned once, and then ceased to function there after?

  def send_message(phone_number, carrier, message):

    CARRIERS = {
        "att": "@mms.att",
        "tmobile": "@tmomail",
        "verizon": "@vtext",
        "sprint": "@messaging.sprintpcs"
    }

    EMAIL = "[email protected]"
    PASSWORD = "paaa ssss word word"

    recipient = phone_number + CARRIERS[carrier]
    auth = (EMAIL, PASSWORD)

    server = smtplib.SMTP("smtp.gmail", 587)
    server.starttls()
    server.login(auth[0], auth[1])

    server.sendmail(auth[0], recipient, message)

本文标签: pythonTrouble Sending Text with smtplibStack Overflow