-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmtp_client.py
More file actions
26 lines (22 loc) · 777 Bytes
/
smtp_client.py
File metadata and controls
26 lines (22 loc) · 777 Bytes
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
import smtplib, ssl
from getpass import getpass
from email.message import EmailMessage
from email.utils import formataddr
email = 'info@dhaownconstruction.com'
password = getpass(f'Enter password for {email}: ')
# receiver = 'mukilteoacademy@gmail.com'
# email = 'admin@advangers.com'
receiver = 'mukilteoacademy@gmail.com'
context = ssl.create_default_context()
print('Context created, trying to connect')
server = smtplib.SMTP_SSL('mail.advangers.com', 465, context=context)
print('Logging in...')
server.login(email, password)
print('Logged in as', email)
msg = EmailMessage()
msg['From'] = formataddr((input('Name to use: '), email))
msg['To'] = receiver
msg['Subject'] = input('Subject: ')
msg.set_content(input('Body: '))
server.send_message(msg)
print('Email sent.')