Skip to content

Instantly share code, notes, and snippets.

@EleazarSauz
Created August 11, 2019 18:59
Show Gist options
  • Select an option

  • Save EleazarSauz/9938648918cf25fad21920d4f437eb47 to your computer and use it in GitHub Desktop.

Select an option

Save EleazarSauz/9938648918cf25fad21920d4f437eb47 to your computer and use it in GitHub Desktop.
send correo
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Eventos y Difusón IIJ</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body style="margin: 0; padding: 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="padding: 10px 0 30px 0;">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="400"
style=" border-collapse: collapse;">
<tr>
<td align="center" bgcolor="#1e2b6b"
style="padding: 40px 0 30px 0; color: #142667; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;">
<img src="http://siev.juridicas.unam.mx/assets/images/logos_unam.png" alt="Creating Email Magic" width="200"
style="display: block;" />
</td>
</tr>
<tr >
<td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;" align="center" >
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" style="color: #142667; font-family: Arial, sans-serif; font-size: 24px;">
<b>HOLA</b>
</td>
</tr>
<tr>
<td align="center" style="color: #b99029; font-family: Arial, sans-serif; font-size: 24px;">
<b>{{username}}</b>
</td>
</tr>
<tr>
<td align="center"
style="padding: 30px 0 40px 0; color: #142667; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
Recuerda que tienes <br>
3 semanas para confirmar <br>
tu evento de lo contrario <br>
será CANCELADO. <br>
<a href="http://siev.juridicas.unam.mx/event/overview/{{link}}">https://link.unam.mx</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#b99029" width="100%" align="center" style="padding: 30px 30px 30px 30px; color: #ffffff; font-family: Arial, sans-serif; font-size: 14px;">
Sistema de Eventos<br />
Instituto de Investigaciones Jurídicas UNAM<br />
<a href="http://siev.juridicas.unam.mx" style="color: #ffffff;">
<font color="#ffffff">siev.juridicas.unam.mx</font>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
from django.template.loader import get_template
from django.core.mail import EmailMultiAlternatives
def send_correo(request):
asunto = 'Tu evento' # Asusnto del correo
text_content = 'Mensaje' # mesaje, este no se envia porque es remplazada por la platilla html
email = ['[email protected]', '[email protected]'] # correo que recibiran el mensaje
html = get_template('mail.html') # este los sacas del las platillas o archivso estaticos que declares en settings.py
username = 'Daniel' # nombre que aprece en el correo envuado
link = 384 # id del evento para que navege directamente en la platilla del correo que se envia
ctx = { # aqui se definen todas las variables que quieras cambiar en la platilla del correo
"username": username,
"link": link
}
html_content = html.render(ctx)
msg = EmailMultiAlternatives(asunto, text_content, '[email protected]', email)
msg.attach_alternative(html_content, "text/html")
msg.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment