I have a web.py project with a notice module – the system will notice users by sending an email with HTML format .
I know how to send HTML format email in python .(Also desc in this Q sendmail with HTML message) , and also know the sendmail() funciton in web.py (version 0.37).
import web
web.config.smtp_server = 'smtp.gmail.com'
web.config.smtp_port = 587
web.config.smtp_username = 'goooooooooooooogle@gmail.com'
web.config.smtp_password = '*********'
web.config.smtp_starttls = True
web.sendmail('goooooooooooooogle@gmail.com',['1361877@gmail.com'],'Hello nodexy','This email is from web.py !')
I expect :
web.sendmail('goooooooooooooogle@gmail.com',['1361877@gmail.com'],'Hello nodexy', '<html><img src="hello.png"/></html>')
Now how can I fix this in web.py ? I’m sure I can not set the HTML string to the sendmail() function .
send html mail, add a key to headers:
in web.py utils.py, see _EmailMessage’s prepare_message method: