smtplib -
The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon. For details of SMTP and ESMTP operation, consult RFC 821 (Simple Mail Transfer Protocol) and RFC1869 (SMTP Service Extensions).
email.message -
The central class in the email package is the EmailMessages class, imported from the email.message module. It is the base class for the email object model. EmailMessage provides the core functionality for setting and querying header fields, for accessing message bodies, and for creating or modifying structured messages.
imghdr -
The imghdr module determines the type of image contained in a file or byte stream.
The imghdr module defines the following function:
imghdr.what(filename, h=None)
Tests the image data contained in the file named by filename, and returns a string describing the image type. If optional h is provided, the filename is ignored and h is assumed to contain the byte stream to test.
import smtplib
import os
rec = "receiver's Email Address"
mail = os.environ.get('USER_ID') #Use the Email Id as an environment variable
pasw = os.environ.get('USER_PASS') #Use the Email password as an environment variable
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login(mail,pasw)
subject = 'Subject of the Email'
body = ' Message body '
msg = f'Subject:{subject}\n\n{body}'
server.sendmail(mail,rec,msg)