-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonly_emails.py
55 lines (46 loc) · 3.46 KB
/
only_emails.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from email.message import EmailMessage
import ssl
import smtplib
# server = smtplib.SMTP('smtp.gmail.com', 587)
# server.starttls()
# server.login('[email protected]', 'bmhvvxwxevtxzmbz')
# content = '''
# Hi, an email from the wizard
# '''
# server.sendmail("[email protected]", "[email protected]", content)
# print("email gone")
from email.message import EmailMessage
msg = EmailMessage()
msg["From"] = "[email protected]"
msg["To"] = "[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]"
# msg["Cc"] = "[email protected], [email protected]"
# msg["Bcc"] = "[email protected], [email protected]"
msg["Subject"] = "Hello from the other side"
msg.set_content('''Sorry to interrupt, this is Stephen,
your fellow slightly Techie student, drop your twitter handl, let us connect,mine is @wizardincarnate''')
# You can put an HTML body instead by ading a subtype string argument "html"
# msg.set_content("<p>This is the main text/html message.</p>", "html")
# You can add attachments of various types as you see fit;
# if there are no other parts, the message will be a simple
# text/plain or text/html, but Python will change it into a
# suitable multipart/related or etc if you add more parts
# with open("image.png", "rb") as picture:
# msg.add_attachment(picture.read(), maintype="image", subtype="png")
# Here, we use SMTP instead of SMTP_SSL, but pivot to encrypted
# traffic with STARTTLS after the initial handshake.
with smtplib.SMTP("smtp.gmail.com", 587) as server:
# Some servers insist on this, others are more lenient ...
# It is technically required by ESMTP, so let's do it
# (If you use server.login() Python will perform an EHLO first
# if you haven't done that already, but let's cover all bases)
server.ehlo()
# Whether or not to use STARTTLS depends on the mail server
server.starttls()
# Bewilderingly, some servers require a second EHLO after STARTTLS!
server.ehlo()
# Login is the norm rather than the exception these days
# but if you are connecting to a local mail server which is
# not on the public internet, this might not be useful or even possible
server.login("jacobantoine506", "bmhvvxwxevtxzmbz")
# Finally, send the message
server.send_message(msg)