Python: “subject” not shown when sending email using smtplib module

后端 未结 7 2096

I am successfully able to send email using the smtplib module. But when the emial is sent, it does not include the subject in the email sent.

import smtplib
         


        
相关标签:
7条回答
  • 2020-12-04 21:44

    try this:

    import smtplib
    from email.mime.multipart import MIMEMultipart
    msg = MIMEMultipart()
    msg['From'] = 'sender_address'
    msg['To'] = 'reciver_address'
    msg['Subject'] = 'your_subject'
    server = smtplib.SMTP('localhost')
    server.sendmail('from_addr','to_addr',msg.as_string())
    
    0 讨论(0)
提交回复
热议问题