add: Email Sender Script

This commit is contained in:
bartick 2022-09-16 23:24:21 +05:30
parent 58847d3648
commit df8072b185
2 changed files with 62 additions and 0 deletions

40
Email Sender/README.md Normal file
View File

@ -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.

22
Email Sender/script.py Normal file
View File

@ -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)