Specify a sender when sending mail with Python (smtplib)

前端 未结 6 1219
不思量自难忘°
不思量自难忘° 2020-12-02 00:19

I have a very simple piece of code (just for testing):

import smtplib
import time

server = \'smtp.myprovider.com\'
recipients = [\'johndoe@somedomain.com\']         


        
6条回答
  •  时光取名叫无心
    2020-12-02 00:38

    I think you are trying to show some specific name instead of your emailID. You need to change only msg['From'] part in this code

    fromName = "Name Which you want to show in reciever Inbox"
    fromEmail = "abc@xyz.com"  # Sender's email Id
    message['From'] = "{} <{}>".format(fromName,fromEmail)
    

    After this usual in above described link.

提交回复
热议问题