-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathemail_alert_function.py
44 lines (34 loc) · 1.36 KB
/
email_alert_function.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
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
def em(receiver):
message = MIMEMultipart('related')
msg_content = '''<html><body>
<p> ALERT Beast, something mischievous happening. Take a close look 🤔 </p>
<p><img src="cid:[email protected]" width="300" height="300"></p>
</body></html>'''
message.attach(MIMEText((msg_content), 'html'))
with open('sp2.jfif', 'rb') as image_file:
image = MIMEImage(image_file.read())
image.add_header('Content-ID', '<[email protected]>')
image.add_header('Content-Disposition', 'inline', filename='sp2.jfif')
message.attach(image)
sender = "[email protected]"
password = "novebhfswebflrzt"
message['From'] = sender
message['To'] = receiver
message['Subject'] = 'Python Test E-mail'
msg_full = message.as_string()
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(sender, password)
server.sendmail(sender,[receiver],msg_full)
server.quit()
# print("Enter number of email_ids you want to register:")
n=int(input("Enter number of email_ids you want to register:"))
lst=[]
for i in range(n):
lst.append(input("Enter the email"))
for gmail in lst:
em(gmail)