2

こんにちは私は簡単なメッセージを送信するPythonスクリプトを作成しました。このスクリプトは、私の大学の電子メールアドレスで機能します。ただし、Gmailでは問題があるようです。私は自分の電子メールとログイン名としてログインするだけの両方を使用してみました-同じ結果です。私が得るエラーは次のとおりです。

Error 252 : b"2.1.5 Send some mail, I'll try my best f18sm1267047wiv.14"

何が間違っているのかわかりません。私は本当に多くの情報を見つけることができませんでした。私が得るのは上記の行だけで、他には何もありません。私はLinuxマシンでスクリプトを実行していて、それはLinuxマシンで書かれています。

#! /usr/bin/python3.1

def sendmail(recepient,  msg):

    import smtplib

    # Parameters
    sender = 'login@gmail.com'
    password = 'password'
    smtpStr = 'smtp.gmail.com'
    smtpPort = 587
    # /Parameters

    smtp_serv = smtplib.SMTP(smtpStr, smtpPort)
    smtp_serv.ehlo_or_helo_if_needed()
    smtp_serv.starttls()
    smtp_serv.ehlo()

    recepientExists = smtp_serv.verify(recepient)
    if recepientExists[0] == 250:
        smtp_serv.login(sender, password)
        try:
            smtp_serv.sendmail(sender, recepient, msg)
        except smtplib.SMTPException:
            print(recepientExists[1])
    else:
        print('Error',   recepientExists[0], ':',  recepientExists[1])

    smtp_serv.quit()

sendmail('receiver@gmail.com',  'hi')
4

1 に答える 1

-1

それはかなり簡単です。VRFYはスパムを助長するものであるため、誰もVRFYをサポートしていません。そのチェックを引き出すと、問題なく動作するはずです。

于 2011-11-08T17:51:50.120 に答える