电子邮件不在收件人和抄送中显示收件人

Emails do not display recipients in To & Cc

我正在尝试使用 python 3.8 中的 smtplib 与我的组织交换邮箱 (Office 265) 发送电子邮件,它可以正常工作,并且确实可以发送电子邮件。

但是,电子邮件不显示带有电子邮件地址的 ToCC;电子邮件像用户使用 Bcc 发送一样发送。请帮忙


EMAIL_ADDRESS = 'mydept_help@myorg.com'
EMAIL_PASS = None

to = 'myemail@myorg.com'

with smtplib.SMTP('outbound.myorg.com', 25) as smtp:
        smtp.ehlo()
        smtp.starttls()
        smtp.ehlo()

        # smtp.login(EMAIL_ADDRESS,EMAIL_PASS)

        subject = 'Test email'
        body = 'Hello, sending email via python'

        msg = f'Subject: {subject}\n\n{body}'

        smtp.sendmail(EMAIL_ADDRESS, to, msg)

print(msg)```

Please note, our organisation lets us configure dummy emails and there is no authentication required; hence skipped *smtp.login* step

您需要将这些详细信息作为 header 行包含在消息中 body:

msg = (f'From: {fromaddr}\r\nTo: {toaddr}\r\nsubject: {subject}\r\n\r\n{body}')