Created
March 27, 2018 21:38
-
-
Save olivx/54a15611d38306eb8db9a6b2b1757b27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.mail import get_connection, EmailMultiAlternatives | |
from django.template.loader import render_to_string | |
connection = get_connection() | |
connection.open() | |
context = {'object': object } | |
html_string = render_to_string('template.html',context=context, request=request) | |
from_email = settings.SERVER_EMAIL | |
msg = EmailMultiAlternatives( | |
subject, html_content, from_email, email_to) | |
# reder html on e-mail body | |
msg.attach_alternative(html_content, "text/html") | |
# if file not existS on server, BOMMMMM!!! | |
msg.attach(cand_cv.resume.name, cand_cv.resume.read()) | |
msg.send() | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment