Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -300,6 +300,17 @@ def send_email_with_attachment(recipient_email, subject, body, image_data):
|
|
| 300 |
|
| 301 |
# Create SMTP session for sending the mail
|
| 302 |
print(body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
with smtplib.SMTP_SSL('smtp.gmail.com', 25) as smtp_server:
|
| 304 |
|
| 305 |
smtp_server.login(sender, password)
|
|
|
|
| 300 |
|
| 301 |
# Create SMTP session for sending the mail
|
| 302 |
print(body)
|
| 303 |
+
context = ssl.create_default_context()
|
| 304 |
+
with smtplib.SMTP(smtp_server, 587) as server:
|
| 305 |
+
server.ehlo() # Can be omitted
|
| 306 |
+
server.starttls(context=context)
|
| 307 |
+
server.ehlo() # Can be omitted
|
| 308 |
+
server.login(sender_email, sender_password)
|
| 309 |
+
text = msg.as_string()
|
| 310 |
+
server.sendmail(sender_email, recipient_email, text)
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
|
| 314 |
with smtplib.SMTP_SSL('smtp.gmail.com', 25) as smtp_server:
|
| 315 |
|
| 316 |
smtp_server.login(sender, password)
|