Spaces:
Sleeping
Sleeping
pragnakalp
commited on
Commit
•
61796aa
1
Parent(s):
ecdecda
Update send_email_user.py
Browse files- send_email_user.py +66 -66
send_email_user.py
CHANGED
@@ -1,86 +1,86 @@
|
|
1 |
-
from email.mime.multipart import MIMEMultipart
|
2 |
-
from email.mime.text import MIMEText
|
3 |
-
from email.mime.image import MIMEImage
|
4 |
import smtplib
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
fromadd = "pragnakalp.dev33@gmail.com"
|
26 |
password = "httscgatatbbxxur"
|
27 |
# SENDGRID_API_KEY = "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"
|
28 |
|
29 |
-
def gmail_login():
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
def send_user_email(hostname,text_output,Method):
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
1 |
+
# from email.mime.multipart import MIMEMultipart
|
2 |
+
# from email.mime.text import MIMEText
|
3 |
+
# from email.mime.image import MIMEImage
|
4 |
import smtplib
|
5 |
|
6 |
+
def send_user_email():
|
7 |
|
8 |
+
sender="pragnakalp.dev33@gmail.com"
|
9 |
+
password="httscgatatbbxxur"
|
10 |
+
reciever="pragnakalp.dev35@gmail.com"
|
11 |
|
12 |
+
s = smtplib.SMTP('smtp.gmail.com', 587)
|
13 |
+
s.starttls()
|
14 |
+
s.login(sender,password)
|
15 |
|
16 |
|
17 |
+
message = """Subject : Appointment Booking\n\n
|
18 |
+
Hello,
|
19 |
+
Your OCR generated successfully"""
|
20 |
+
s.sendmail(sender, reciever, message)
|
21 |
+
s.quit()
|
22 |
+
mailsend=1
|
23 |
+
return "Hellowwass"
|
24 |
|
25 |
fromadd = "pragnakalp.dev33@gmail.com"
|
26 |
password = "httscgatatbbxxur"
|
27 |
# SENDGRID_API_KEY = "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"
|
28 |
|
29 |
+
# def gmail_login():
|
30 |
+
# try:
|
31 |
+
# server = smtplib.SMTP('smtp.gmail.com', 587)
|
32 |
+
# server.starttls()
|
33 |
+
# server.login(fromadd, password)
|
34 |
+
# return server
|
35 |
+
# except Exception as e:
|
36 |
+
# print("*** MAIL ERROR ***"*10)
|
37 |
+
# print(e)
|
38 |
|
39 |
+
# def send_user_email(hostname,text_output,Method):
|
40 |
|
41 |
+
# try:
|
42 |
+
# # attachment = input_img
|
43 |
+
# html_body=""
|
44 |
+
# html_body = f"""<html>
|
45 |
+
# <body>
|
46 |
+
# <p>
|
47 |
+
# {hostname}<br/>
|
48 |
+
# Method: {Method}<br/>
|
49 |
+
# Generated text: {text_output}<br/>
|
50 |
+
# </p>
|
51 |
+
# <br />
|
52 |
+
# </body>
|
53 |
+
# </html>"""
|
54 |
|
55 |
+
# toadd = "pragnakalp.dev35@gmail.com"
|
56 |
+
# subject = "OCR generated text"
|
57 |
|
58 |
+
# msg = MIMEMultipart("alternative")
|
59 |
|
60 |
+
# msg['From'] = fromadd
|
61 |
+
# msg['To'] = toadd
|
62 |
+
# msg['Subject'] = subject
|
63 |
|
64 |
+
# # part1 = MIMEText(text, "plain")
|
65 |
+
# # part2 = MIMEText(html_body, "html")
|
66 |
+
# # msg.attach(part1)
|
67 |
|
68 |
+
# # part2 = MIMEText('<b>%s</b><br/><img src="cid:%s"/><br/>' % (html_body, attachment), 'html')
|
69 |
+
# part2 = MIMEText(html_body, "html")
|
70 |
+
# msg.attach(part2)
|
71 |
+
# # with open(attachment, 'rb') as fp:
|
72 |
+
# # img = MIMEImage(fp.read())
|
73 |
+
# # img.add_header('Content-ID', '<{}>'.format(attachment))
|
74 |
+
# # msg.attach(img)
|
75 |
|
76 |
+
# server = gmail_login()
|
77 |
+
# print("login success")
|
78 |
+
# temp = server.sendmail(fromadd, toadd, msg.as_string())
|
79 |
+
# print("temp=.", temp)
|
80 |
+
# print("email sent to", toadd)
|
81 |
|
82 |
+
# print("** Mail Successfully Sent !***")
|
83 |
+
# return True
|
84 |
+
# except Exception as e:
|
85 |
+
# print("Error while sending feedback email => ", e)
|
86 |
+
# return False
|