smtplib的SMTP服务器登录失败

时间:2015-03-27 22:24:58

标签: python smtp smtplib

我已经编写了一个从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()

有没有人对为什么会失败有任何想法?我已尝试使用大量电子邮件和密码(所有帐户我实际拥有),并且每次都失败。这是发生在Google的最后吗?

1 个答案:

答案 0 :(得分:0)

默认情况下,无法访问Gmail的POP3 / IMAP / SMTP服务器。如果要使用它们,则必须手动打开它们。