| 123456789101112131415161718192021222324252627282930 |
- import smtplib
- from email.message import EmailMessage
- from logging import getLogger
- logger = getLogger(__name__)
- def send_email(
- subject: str,
- body: str,
- to: list[str],
- **kwargs
- ):
- logger.debug(str(kwargs))
- """Send email """
- # Datos del remitente
- EMAIL_ORIGEN = 'expresspedidos211@gmail.com'
- CONTRASENA = 'drkassszdtgapufg'
- # Crear el correo
- msg = EmailMessage()
- msg['Subject'] = subject
- msg['From'] = EMAIL_ORIGEN
- msg['To'] = ", ".join(to)
- msg.set_content('Este correo tiene contenido HTML.')
- msg.add_alternative(body.format(**kwargs), 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)
|