Created two automated scripts which will send an email with attachments.
First script uses pdf-mail library and sends an email with a pdf file as an attachment.
Second script will send an email with some template as an email body and also with attachment(i.e. pdf, jpg, txt).
Task Description :
Python, being a powerful language doesn’t need any external library to import and offers a native library to send emails- “SMTP lib”. “smtplib” creates a Simple Mail Transfer Protocol client session object which is used to send emails to any valid email id on the internet. Different websites use different port numbers. I am using a Gmail account to send mail. The Port number used here is ‘587’.
Google is not allowing you to log in via smtplib because it has flagged this sort of login as "less secure", so what you have to do is go to this link while you're logged in to your google account, and allow the access: