Send an email with a profile picture (avatar) using Python through Gmail

37 Views Asked by At

I have a profile picture set for [email protected], however, when I send an email with Python using smtplib and MIMEMultipart the profile picture does not show up for the reciever. I authenticate myself using the following way:

    with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp_server:
        smtp_server.login(send_from, password)
        smtp_server.sendmail(send_from, recipient, msg.as_string())

where msg = MIMEMultipart('related').

I have come across with BIMI, however, I have no idea how to implement that by using Gmail instead of my own domain. For this project, I must use Gmail.

EDIT:

The e-mail is constructed in the following way:

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr

body: str = "Help me!"
msg = MIMEMultipart('related')
msg.attach(MIMEText(body, 'html'))
msg['Subject'] = "Not working"
msg['From'] = formataddr(("John", "[email protected]"))
msg['To'] = "[email protected]"
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp_server:
    smtp_server.login("[email protected]", "THIS_is_My_Password")
    smtp_server.sendmail("[email protected]", "[email protected]", msg.as_string())
0

There are 0 best solutions below