I am testing the sending of an email with an embeded png file. I use the code:
from smtplib import SMTP
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
template ="""
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Image Test</h2>
<img src="/home/depot/wintergreen/mplplots/01.png">
</body>
</html>"""
MAIL_HOST = 'smtp.gmail.com:587'
MAIL_USER = 'xxx@gmail.com'
MAIL_PASSWORD = 'xxx'
MAIL_REPICIENTS = ['vincent.konate@gmail.com']
message = MIMEMultipart('alternative')
message['Subject'] = "Test Image"
html = MIMEText(template, 'html', "utf-8")
message.attach(html)
smtp = SMTP(MAIL_HOST)
smtp.ehlo()
smtp.starttls()
smtp.login(MAIL_USER, MAIL_PASSWORD)
smtp.sendmail(MAIL_USER, MAIL_REPICIENTS, message.as_string())
smtp.close()
The sending works, however the image doesnt show up, instead this is what I see:
I am testing with the Jupyter notebook; When i type
from IPython.display import Image
Image("/home/depot/wintergreen/mplplots/01.png")
The image shows, so the path is correct.
What could be wrong here?