From df8072b185060ee309ffc9364aeab928d25aa91f Mon Sep 17 00:00:00 2001 From: bartick Date: Fri, 16 Sep 2022 23:24:21 +0530 Subject: [PATCH] add: Email Sender Script --- Email Sender/README.md | 40 ++++++++++++++++++++++++++++++++++++++++ Email Sender/script.py | 22 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Email Sender/README.md create mode 100644 Email Sender/script.py diff --git a/Email Sender/README.md b/Email Sender/README.md new file mode 100644 index 0000000..f9898bb --- /dev/null +++ b/Email Sender/README.md @@ -0,0 +1,40 @@ +## Check-System-Usage + +![built by developers](http://ForTheBadge.com/images/badges/built-by-developers.svg) +![python](https://img.shields.io/badge/language-Python-orange?style=for-the-badge) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=plasitc)](https://github.com/psf/black) +![License](https://img.shields.io/github/license/GDSC-RCCIIT/General-Purpose-Scripts?color=blue&style=plasitc) + +### About + +A Python3 script to automate the email sending process + +### Setup + +* Install Python3 for Windows from [here](https://python.org). +* Open Windows Command Prompt +* Clone the repository + ```bash + git clone https://github.com/GDSC-RCCIIT/General-Purpose-Scripts.git + ``` +* Navigate inside the ```scripts\Email-Sender``` directory. + ```bash + cd General-Purpose-Scripts\scripts\Email-Sender + ``` +* Run using Python + ```bash + python system-usage.py + ``` +Note: Make sure you have enabled the "Less Secure Apps" from Google account security +to send emails using that script. + +### Steps to Allow Less Secure Apps + + * Visit: https://myaccount.google.com/intro/security + * Disable 2-Step Verification if enabled (See the image below). + ![Screenshot (504)](https://user-images.githubusercontent.com/73809690/135844785-6bb4aaf1-b647-4d79-aa1d-742117a8547e.png) + + * Then Turn On Less Secure Apps (See the image below) + ![Screenshot (505)](https://user-images.githubusercontent.com/73809690/135844893-43e10b99-2a84-4637-af4b-192afb8c1e4d.png) + + * Now you are good to go. \ No newline at end of file diff --git a/Email Sender/script.py b/Email Sender/script.py new file mode 100644 index 0000000..d12d250 --- /dev/null +++ b/Email Sender/script.py @@ -0,0 +1,22 @@ +# Script to automate Email Sending +"""Note: To run this script enable "Less Secure Apps" shown in Readme file""" +import smtplib + +to = input("Enter the Email of recipent:\n") +content = input("Enter the Content for E-Mail:\n") + +sender_email = input("Enter Your Email Address: ") +sender_password = input("Enter Your Password: ") + + +def sendEmail(to, content): + server = smtplib.SMTP("smtp.gmail.com", "587") + server.ehlo() + server.starttls() + server.login(sender_email, sender_password) + server.sendmail(sender_email, to, content) + server.close() + print("Email Successfully send\n") + + +sendEmail(to, content) \ No newline at end of file