我尝试使用smtplib python软件包使用主帐户的用户名和密码以及共享邮箱的发件人电子邮件进行身份验证,但是得到了:
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def send_email(username, password, sender, receiver, subject, body):
message = MIMEMultipart("alternative")
message["Subject"] = subject
message["From"] = sender
message["To"] = receiver
message.attach(MIMEText(body, "html"))
with smtplib.SMTP("smtp.office365.com", 587) as server:
server.ehlo()
server.starttls()
server.login(username, password)
server.sendmail(sender, receiver, message.as_string())
return 'email sent to {}'.format(receiver)
ERROR_MSG: SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful [PN1PR0101CA0041.INDPRD01.PROD.OUTLOOK.COM]')
请扩展您的专业知识,以了解如何使用python中的smtplib使用共享邮箱发送电子邮件。