最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Trouble Sending Text with smtplib - Stack Overflow

programmeradmin0浏览0评论

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)
发布评论

评论列表(0)

  1. 暂无评论