[英]Securely send email from custom gsuit domain in python Django
我有兩封 gsuit 電子郵件:
我想使用 python3.7 從 user@mydomain.com 安全地發送電子郵件我為user@mydomain.com
創建了user@mydomain.com
並在 Django 中嘗試了以下代碼:settings.py:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'user@mydomain.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxx'
EMAIL_PORT = 587
主功能:
message = render_to_string('app1/email.html', {
'fn': ip_dict['first_name'], 'ln': ip_dict['last_name']
})
send_mail(
'hello world',
'',
'user@mydomain.com',
[ip_dict['email']],
html_message=message,
)
我得到錯誤:
SMTPAuthenticationError at /url/
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials v5sm4332617otk.64 - gsmtp')
使用 app_password,安全級別較低。 使用 google gmail API https://developers.google.com/gmail/api/quickstart/python,該應用程序打開瀏覽器並讓我實際登錄。有沒有其他安全的方式從 gmail 自動發送電子郵件。 謝謝
托管在 Gitlab 上的 Jupyter 筆記本中的詳細解決方案: 鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.