Use python automatic e-mail: yagmail library

yagmail library is a very simple way to send the message.

Installation: pip install yagmail

Import yagmail 
YAG = yagmail.SMTP (= User ' [email protected] ' , password = ' jahsxxxxxxgag ' , Host = ' smtp.qq.com ' ) # parameter sent mailbox, the mailbox password (authorization code), transmits mailbox server 
Content = '' ' Dear All: 
                the following are the quarter as of yesterday leads situation broadcast: ' 
          '' 
# -mail text, is a list of 
Contents = [
             " <h1 style = 'Color: Red'> Lead analysis </ h1> " , # can be html language 
            Content, # can be plain text 
#              'Beauty.jpg ', # may be a file, sent as an attachment
            yagmail.inline (r ' D: \ QQPCMgr \ pc.jpg ' ), # so, the picture will be embedded in the text Caution: Do not directly copy the path of illegal characters recommend hand knock 
            
            ] 

yag.send (to = ' 59xxxxx30 @ QQ .com ' , Subject = ' test message ' , = Contents Contents)

Mail style:

 

Guess you like

Origin www.cnblogs.com/mozhujun/p/11588489.html