File size: 3,271 Bytes
1c84ad3
 
 
 
 
 
 
 
450e3d8
1c84ad3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7fa442
3c9e41a
1c84ad3
3c9e41a
1c84ad3
3c9e41a
1c84ad3
 
 
 
4c5a5c3
 
 
 
 
450e3d8
4c5a5c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7fa442
3c9e41a
4c5a5c3
3c9e41a
4c5a5c3
3c9e41a
4c5a5c3
 
 
 
1c84ad3
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
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
87
88
89
90
91
92
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import os

def send_email_notification(name, email, institution, role, reason):
    sender_email = "noreply@aideatext.ai"  # Configura esto con tu direcci贸n de correo
    receiver_email = "hello@aideatext.ai"
    password = os.environ.get("NOREPLY_EMAIL_PASSWORD")  # Configura esto en tus variables de entorno

    message = MIMEMultipart("alternative")
    message["Subject"] = "Nueva solicitud de prueba de AIdeaText"
    message["From"] = sender_email
    message["To"] = receiver_email

    text = f"""\
    Nueva solicitud de prueba de AIdeaText:
    Nombre: {name}
    Email: {email}
    Instituci贸n: {institution}
    Rol: {role}
    Raz贸n: {reason}
    """

    html = f"""\
    <html>
      <body>
        <h2>Nueva solicitud de prueba de AIdeaText</h2>
        <p><strong>Nombre:</strong> {name}</p>
        <p><strong>Email:</strong> {email}</p>
        <p><strong>Instituci贸n:</strong> {institution}</p>
        <p><strong>Rol:</strong> {role}</p>
        <p><strong>Raz贸n:</strong> {reason}</p>
      </body>
    </html>
    """

    part1 = MIMEText(text, "plain")
    part2 = MIMEText(html, "html")

    message.attach(part1)
    message.attach(part2)

    try:
        with smtplib.SMTP_SSL("smtp.titan.email", 465) as server:
            logger.info("Conectado al servidor SMTP")
            server.login(sender_email, password)
            logger.info("Inicio de sesi贸n exitoso")
            server.sendmail(sender_email, receiver_email, message.as_string())
            logger.info(f"Correo enviado de {sender_email} a {receiver_email}")
        logger.info(f"Email notification sent for application request: {email}")
        return True
    except Exception as e:
        logger.error(f"Error sending email notification: {str(e)}")
        return False

def send_user_feedback_notification(name, email, feedback):
    sender_email = "noreply@aideatext.ai"
    receiver_email = "feedback@aideatext.ai"  # Cambia esto a la direcci贸n que desees
    password = os.environ.get("NOREPLY_EMAIL_PASSWORD")

    message = MIMEMultipart("alternative")
    message["Subject"] = "Nuevo comentario de usuario en AIdeaText"
    message["From"] = sender_email
    message["To"] = receiver_email

    html = f"""\
    <html>
      <body>
        <h2>Nuevo comentario de usuario en AIdeaText</h2>
        <p><strong>Nombre:</strong> {name}</p>
        <p><strong>Email:</strong> {email}</p>
        <p><strong>Comentario:</strong> {feedback}</p>
      </body>
    </html>
    """

    part = MIMEText(html, "html")
    message.attach(part)

    try:
        with smtplib.SMTP_SSL("smtp.titan.email", 465) as server:
            logger.info("Conectado al servidor SMTP")
            server.login(sender_email, password)
            logger.info("Inicio de sesi贸n exitoso")
            server.sendmail(sender_email, receiver_email, message.as_string())
            logger.info(f"Correo enviado de {sender_email} a {receiver_email}")
        logger.info(f"Email notification sent for user feedback from: {email}")
        return True
    except Exception as e:
        logger.error(f"Error sending user feedback email notification: {str(e)}")
        return False