I'm generating emails using Python's smtplib
, and I'm trying to re-create a signature to place at the bottom of each email. Below is a highly detailed and masterful recreation of this signature:
The text portion I've already got figured out.
body = """\
<html>
<head></head>
<body>
stuff
</body>
</html>
"""
Which I then attach to the message:
message_body = MIMEText(body, 'html')
message.attach(message_body)
What I can't seem to figure out is how to then embed the images so they're formatted like in the picture above. The lines in the picture are just to show alignment, but they don't exist in the signature itself. The images also contain hyperlinks.
I've tried something like adding this to the very end of the <body>
tag to at least recreate the smaller images at the bottom:
<img src="C:\Users\Me\Desktop\image1.png">
<img src="C:\Users\Me\Desktop\image2.png">
I don't get any errors, but also nothing shows up when the email is sent. I don't know how I would begin formatting the larger image that should sit to the left of the text in the signature.
I can successfully include these images in the email as attachments using MIMEImage
, but I don't want them as attachments, so that didn't work.
After the images are embedded as above, I assume I could just do something like this to add in the hyperlinks:
<a href="https://www.example.com">
<img src="img1.png" alt="example.com">
</a>
I'm new to HTML so these are uncharted waters for me, and I'm not sure what to do. I've read a lot of questions here that also mention base64 encoding, but I don't know if it applies to this situation.
Any help would be appreciated. Thanks!
Edit: New question posted here to address the issue that, once encoded and sent, the images in the sent email are showing up as blank.