Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -240,6 +240,41 @@ def document_data_tool(question):
|
|
240 |
|
241 |
def send_email_with_attachment(recipient_email, subject, body, attachment_path):
|
242 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
sender_email = os.getenv("EMAIL_SENDER")
|
244 |
sender_password = os.getenv("EMAIL_PASSWORD")
|
245 |
# Create a multipart message
|
@@ -276,7 +311,7 @@ def send_email_with_attachment(recipient_email, subject, body, attachment_path):
|
|
276 |
print("Email sent successfully")
|
277 |
except Exception as e:
|
278 |
print(f"Error occurred: {str(e)}")
|
279 |
-
|
280 |
server.starttls()
|
281 |
server.login(sender_email, sender_password)
|
282 |
text = msg.as_string()
|
|
|
240 |
|
241 |
def send_email_with_attachment(recipient_email, subject, body, attachment_path):
|
242 |
try:
|
243 |
+
from fastapi import FastAPI
|
244 |
+
|
245 |
+
from fastapi_mail import FastMail, MessageSchema, ConnectionConfig, MessageType
|
246 |
+
from pydantic import EmailStr, BaseModel
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
conf = ConnectionConfig(
|
251 |
+
MAIL_USERNAME = "redmind",
|
252 |
+
MAIL_PASSWORD = "jymzapycraiheubg",
|
253 |
+
MAIL_FROM = "redmind.uiautomation@gmail.com",
|
254 |
+
MAIL_PORT = 587,
|
255 |
+
MAIL_SERVER = "smtp.gmail.com",
|
256 |
+
MAIL_FROM_NAME="redmind",
|
257 |
+
MAIL_STARTTLS = True,
|
258 |
+
MAIL_SSL_TLS = False,
|
259 |
+
USE_CREDENTIALS = True,
|
260 |
+
VALIDATE_CERTS = True
|
261 |
+
)
|
262 |
+
|
263 |
+
html = """<p>Hi this test mail, thanks for using Fastapi-mail</p> """
|
264 |
+
|
265 |
+
message = MessageSchema(
|
266 |
+
subject="Fastapi-Mail module",
|
267 |
+
recipients=recipient_email,
|
268 |
+
body=html,
|
269 |
+
subtype=MessageType.html)
|
270 |
+
|
271 |
+
fm = FastMail(conf)
|
272 |
+
await fm.send_message(message)
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
|
277 |
+
"""
|
278 |
sender_email = os.getenv("EMAIL_SENDER")
|
279 |
sender_password = os.getenv("EMAIL_PASSWORD")
|
280 |
# Create a multipart message
|
|
|
311 |
print("Email sent successfully")
|
312 |
except Exception as e:
|
313 |
print(f"Error occurred: {str(e)}")
|
314 |
+
server = smtplib.SMTP('smtp.gmail.com', 587)
|
315 |
server.starttls()
|
316 |
server.login(sender_email, sender_password)
|
317 |
text = msg.as_string()
|