2016-11-17 6 views
-1

でGmailからメールを送信私はジャンゴで電子メールを送信に関する記事をたくさん見つけましたが、私はGmailを使用し、特定の問題ました:ここはジャンゴとPython

error image

を私の設定です:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' 
EMAIL_HOST = "smtp.gmail.com" 
EMAIL_HOST_USER = "[email protected]" 
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER 
EMAIL_HOST_PASSWORD = 'mypassword 
EMAIL_PORT = 587 
EMAIL_USE_TLS = True 

と私の見解は以下のとおりです。

from django.core.mail import EmailMessage, send_mail 

    if request.method == 'POST': 
     name = request.POST.get('name','') 
     email = request.POST.get('email','') 
     subject = request.POST.get('subject','') 
     text = request.POST.get('text','') 

     message = 'From: ' + email + '\n\n\n' + text 

     send_mail(subject, message, '[email protected]', ['[email protected]'], fail_silently=False) 

私はこの電子を取得する理由を教えてくださいことができます不具合? 「安全性の低いアプリケーションからのアクセス」などのGoogle設定も確認しました

ありがとうございました!

編集

私はすでに安全性の低いアプリケーションを許可してます。また、これを試すことができ、ロック解除キャプチャ

+1

すでにhttp://stackoverflow.com/questions/26697565/django-smtpauthenticationerror](http://stackoverflow [答えました。 com/questions/26697565/django-smtpauthenticationerror) – betonimig

+0

それは役に立たなかった。私はすでにそれをやったことが...しかし、問題は同じことを続ける – scotch

答えて

0

にクリックしました。

import smtplib 

def send_mail(request): 
    try: 
     subject = "Email Subject" 
     description ="description" 

     gmail_user = "[email protected]" # email id from where you want send mail 
     gmail_pwd ="password" 
     FROM = 'Admin: <[email protected]>' 
     TO = "[email protected]" #email id where you want send mail 
     TEXT = description 
     SUBJECT = subject 
     server = smtplib.SMTP_SSL() 
     server = smtplib.SMTP("smtp.gmail.com", 587) 
     server.ehlo() 
     server.starttls() 

     server.login(gmail_user, gmail_pwd) 
     message = """From: %s\nTo: %s\nSubject: %s\n\n%s """ % (FROM, ", ".join(TO), SUBJECT, TEXT) 
     server.sendmail(FROM, TO, message) 
     server.quit()  
    except Exception,e: 
     print 'exception',e 
+0

続き... – scotch

0

ハイテクextentioすなわちGmailを使用していない電子メールIDを追加し確認してください

EMAIL_HOST_USER = "myemail"