smtplib的SMTP服务器登录失败

2024-10-01 13:27:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我写了一个函数,从gmail帐户给verizon手机发短信,登录到smtp服务器时遇到问题。函数如下所示:

def _text(fromwhom,number,text):
    """
    A private function which sends an SMS message to a cell phone number.

    Parameters
    ----------
    fromwhom : string
        The email address sending the alert: "testing@gmail.com"
    number : string
        The user-provided cell phone receiving the job alert.
    text : string
        The content of the job alert.
    """

    server = smtplib.SMTP( "smtp.gmail.com", 587 )
    server.starttls()
    server.login(account_email, account_pw)
    server.sendmail( '{}'.format(fromwhom), '{}@vtext.com'.format(number), '{}'.format(text) )
    server.quit()

有人知道为什么会失败吗?我尝试过很多电子邮件和密码(都是我自己的账户),每次都失败。这是在谷歌那边发生的吗?在


Tags: the函数textcomformatnumberstringserver