在我的应用程序中,我曾经通过 Gmail smtp 发送电子邮件,但该选项已被 Google 禁用,因为我今天早上在完成应用程序时才发现。我还有哪些其他选择?我知道雅虎,我尝试注册一个帐户,但这也给出了一个已知错误:“尝试次数过多”。稍后可能会尝试,但与此同时,
我还有哪些其他选项可以通过我的应用程序发送电子邮件?它是我的应用程序不可或缺的一部分,因此非常感谢您的帮助,谢谢。
此功能正在运行并且当前正在使用
import smtplib
import ssl
from email.message import EmailMessage
def send_email(body, email_receiver):
# Email subject
subject = 'Validation'
# Gmail SMTP server settings
smtp_server = 'smtp.gmail.com'
smtp_port = 587
# Gmail account credentials
email_sender = '[email protected]'
email_password = 'xxxx xxxx xxxx xxxx'
email_receiver = '[email protected]'
subject = 'Validation'
body = 'testing 6digit'
em = EmailMessage()
em['From'] = email_sender
em['To'] = email_receiver
em['subject'] = subject
em.set_content(body)
context = ssl.create_default_context()
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
smtp.login(email_sender, email_password)
smtp.sendmail(email_sender, email_receiver, em.as_string())