Update modules/email/email.py
Browse files- modules/email/email.py +34 -0
modules/email/email.py
CHANGED
@@ -49,4 +49,38 @@ def send_email_notification(name, email, institution, role, reason):
|
|
49 |
return True
|
50 |
except Exception as e:
|
51 |
logger.error(f"Error sending email notification: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return False
|
|
|
49 |
return True
|
50 |
except Exception as e:
|
51 |
logger.error(f"Error sending email notification: {str(e)}")
|
52 |
+
return False
|
53 |
+
|
54 |
+
def send_user_feedback_notification(name, email, feedback):
|
55 |
+
sender_email = "noreply@aideatext.ai"
|
56 |
+
receiver_email = "feedback@aideatext.ai" # Cambia esto a la dirección que desees
|
57 |
+
password = os.environ.get("EMAIL_PASSWORD")
|
58 |
+
|
59 |
+
message = MIMEMultipart("alternative")
|
60 |
+
message["Subject"] = "Nuevo comentario de usuario en AIdeaText"
|
61 |
+
message["From"] = sender_email
|
62 |
+
message["To"] = receiver_email
|
63 |
+
|
64 |
+
html = f"""\
|
65 |
+
<html>
|
66 |
+
<body>
|
67 |
+
<h2>Nuevo comentario de usuario en AIdeaText</h2>
|
68 |
+
<p><strong>Nombre:</strong> {name}</p>
|
69 |
+
<p><strong>Email:</strong> {email}</p>
|
70 |
+
<p><strong>Comentario:</strong> {feedback}</p>
|
71 |
+
</body>
|
72 |
+
</html>
|
73 |
+
"""
|
74 |
+
|
75 |
+
part = MIMEText(html, "html")
|
76 |
+
message.attach(part)
|
77 |
+
|
78 |
+
try:
|
79 |
+
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
|
80 |
+
server.login(sender_email, password)
|
81 |
+
server.sendmail(sender_email, receiver_email, message.as_string())
|
82 |
+
logger.info(f"Email notification sent for user feedback from: {email}")
|
83 |
+
return True
|
84 |
+
except Exception as e:
|
85 |
+
logger.error(f"Error sending user feedback email notification: {str(e)}")
|
86 |
return False
|