-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailSenderV1.py
31 lines (22 loc) · 1 KB
/
EmailSenderV1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import smtplib, ssl
import getpass
"""
This project was completed as a code along using this guide -> https://realpython.com/python-send-email/
# Make sure to setup a local SMTP debugging server :- python -m smtpd -c DebuggingServer -n localhost:1025
TODOs:-
1. Create a simple function that takes in a user defined sender, receiver, subject, and body using the terminal
2. Allow someone to send emails using a GUI ✅ see SendingSimpleEmailV2.py file
"""
# Sender and Receiver Emails
sender = "throwawaynon54321@gmail.com"
receiver = "throwawaynon54321@gmail.com"
message = 'Subject: Hello World :D' + '\n\n' + 'Lorem Ipsum'
# Gmail requires that port 465 be used if connecting using SMTP_SSL
port = 465
# Creating a secure SSL context
context = ssl.create_default_context()
# Prevents the password being stored within the code
password = getpass.getpass()
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login(sender, password)
server.sendmail(sender, receiver, message)