From 5a16226a1cb1cc4b7d31960de7114f416497f295 Mon Sep 17 00:00:00 2001 From: deepu14d Date: Tue, 26 Oct 2021 22:33:06 +0530 Subject: [PATCH 1/2] Mail Sender added --- Automate GMAIL/index.html | 8 ++++++++ Automate GMAIL/send_mail.py | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Automate GMAIL/index.html create mode 100644 Automate GMAIL/send_mail.py diff --git a/Automate GMAIL/index.html b/Automate GMAIL/index.html new file mode 100644 index 0000000..a39213f --- /dev/null +++ b/Automate GMAIL/index.html @@ -0,0 +1,8 @@ + + + + + + This is the sample content of sample mail getting send using python file. + + diff --git a/Automate GMAIL/send_mail.py b/Automate GMAIL/send_mail.py new file mode 100644 index 0000000..a26a14d --- /dev/null +++ b/Automate GMAIL/send_mail.py @@ -0,0 +1,22 @@ + +""" Everything with $ need to be replaced""" + +import smtplib +from email.message import EmailMessage +from string import Template +from pathlib import Path + +html_file = Template(Path('index.html').read_text()) #index.html is a file we are using to make our mail specific +email = EmailMessage() +email['from'] = '$YOUR_NAME' +email['to'] = '$EMAIL_OF_RECEIVER' +email['subject'] = '$SUBJECT' + +email.set_content(html_file.substitute(name ='$NAME_HERE'), 'html') + +with smtplib.SMTP(host='smtp.gmail.com', port=587) as smtp: + smtp.ehlo() + smtp.starttls() + smtp.login('$YOUR_GMAIL_HERE', '$PASSWORD_HERE') + smtp.send_message(email) + print('Mail sended') \ No newline at end of file From a448829d969e72021bb627443011a505c9292758 Mon Sep 17 00:00:00 2001 From: deepu14d Date: Tue, 26 Oct 2021 22:34:33 +0530 Subject: [PATCH 2/2] Mail Sender Added --- {Automate GMAIL => MAIL Sender}/index.html | 0 {Automate GMAIL => MAIL Sender}/send_mail.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {Automate GMAIL => MAIL Sender}/index.html (100%) rename {Automate GMAIL => MAIL Sender}/send_mail.py (100%) diff --git a/Automate GMAIL/index.html b/MAIL Sender/index.html similarity index 100% rename from Automate GMAIL/index.html rename to MAIL Sender/index.html diff --git a/Automate GMAIL/send_mail.py b/MAIL Sender/send_mail.py similarity index 100% rename from Automate GMAIL/send_mail.py rename to MAIL Sender/send_mail.py