| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import smtplib
- from email.message import EmailMessage
- def send_email():
- """Send email notification when printer is disconnected"""
- # Datos del remitente
- EMAIL_ORIGEN = 'expresspedidos211@gmail.com'
- EMAIL_DESTINO = ['erwinjacimino2003@gmail.com', "mompyn@gmail.com"]
- CONTRASENA = 'drkassszdtgapufg'
- # Crear el correo
- msg = EmailMessage()
- msg['Subject'] = 'Impresora Desconectada weon :('
- msg['From'] = EMAIL_ORIGEN
- msg['To'] = ", ".join(EMAIL_DESTINO)
- msg.set_content('Este correo tiene contenido HTML.')
- msg.add_alternative("""
- <html>
- <body style="margin:0; padding:0; background-color:#5a67d8; font-family: Arial, sans-serif;">
- <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="padding: 40px 0;">
- <tr>
- <td align="center">
- <table border="0" cellpadding="0" cellspacing="0" width="500" style="background-color: #e3e3e3; border-radius: 25px; padding: 40px; text-align: center;">
- <tr>
- <td>
- <div style="font-size: 60px; background-color: #ff6b6b; width: 80px; height: 80px; line-height: 80px; border-radius: 15px; margin: 0 auto 20px; color: white;">
- 🖨️
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <img src="https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExZGlraDhpb2tkeHEweDZ2eWdnZDZlNXFvODhmNzZieWN6OXp0b3ZqNCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3hetVnNSl0IBa/giphy.gif" alt="Gatito peleando con la impresora" width="250" style="border-radius: 12px; margin-bottom: 20px;" />
- </td>
- </tr>
- <tr>
- <td>
- <h1 style="font-size: 24px; color: #ff6b6b; margin-bottom: 10px;">¡Impresora Desconectada!</h1>
- </td>
- </tr>
- <tr>
- <td>
- <p style="font-size: 16px; color: #333333; line-height: 1.5; margin-bottom: 20px;">
- No se puede establecer conexión con la impresora.<br>
- Por favor, verifica la conexión y vuelve a intentarlo.
- </p>
- </td>
- </tr>
- <tr>
- <td>
- <span style="display: inline-block; background: #ff6b6b; color: white; padding: 12px 24px; border-radius: 25px; font-weight: bold; font-size: 16px;">
- 🔴 Estado: Desconectada
- </span>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
- </html>
- """, subtype='html')
- # Enviar el correo usando SMTP de Gmail
- with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
- smtp.login(EMAIL_ORIGEN, CONTRASENA)
- smtp.send_message(msg)
|