pythonのSMTPのGmailの認証エラー(GmailのSMTPサーバを経由してメールを送信します)

StackOverflow https://stackoverflow.com/questions/1384535

  •  21-09-2019
  •  | 
  •  

質問

私持って、次のコード

import smtplib
from email.mime.text import MIMEText



smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = 'admin@myhost.com'  # for SMTP AUTH, set SMTP username here
smtppass = '123456'  # for SMTP AUTH, set SMTP password here

RECIPIENTS = ['online8@gmail.com']
SENDER = 'admin@myhost.com'

msg = MIMEText('dsdsdsdsds\n')
msg['Subject'] = 'The contents of iii'
msg['From'] = 'admin@myhost.com'
msg['To'] = ''online8@gmail.com''

mailServer = smtplib.SMTP('smtp.gmail.com',587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(smtpuser, smtppass)
mailServer.sendmail(smtpuser,RECIPIENTS,msg.as_string())
mailServer.close()

は、このコードは私のデスクトップ上の罰金を動作します。それは、このエラーで失敗しました。

smtplib.SMTPAuthenticationError: (535, '5.7.1 Username and Password not accepted. Learn more at\n5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 21sm4713429agd.11')
私のLinuxサーバ上の

わからない何が悪かったのか、私は?私のLinuxサーバ上でいくつかのポートを開く必要があります。

役に立ちましたか?

解決

ポート587は明らかにオープンにする必要があるが、それはおそらくです(または、あなたは、問題の詳細なエラーMSGを得なかったであろう)。 2.6対のPython 2.5には何の違いを作るべきではありません。私は、問題はログインが現在拒否取得しているため、コンピュータ上に一度「キャプチャを解決する」と関係していると思います。エラーメッセージ内のURLの詳細な手順に従ってください、すなわち、のhttp:/ /mail.google.com/support/bin/answer.py?answer=14257する

他のヒント

import random,time
for i in range(1,100):
    y=random.randint(30,300)
    time.sleep(y)
    print ("Mailing for fun, Mail No: " + str(i))
    msg = MIMEText('Testing mailing \n Mail No:' + str(i))
    msg['Subject'] = 'Mail Number: ' + str(i)

SMTPの動作を確認するために、メールの間隔をランダム:)

ビット加算nは修正して、私たちの断続的なメールのバウンスをチェックする作業にこれを得ています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top