Last active
April 10, 2016 17:55
-
-
Save dogancankilment/4612a595113b2adc3d6ba97fc243586c to your computer and use it in GitHub Desktop.
Sending email with django and using token generator
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 EmailMultiAlternatives | |
from django.template import Context | |
from django.template.loader import render_to_string | |
from django.http import HttpResponse | |
from django.utils.translation import ugettext as _ | |
from .util_token_generator import activation_key_generator | |
def mail_sender(email, controll): | |
subject, from_email = 'hello',\ | |
'your@mail.com' | |
if email: | |
to = email | |
hash_key_example = activation_key_generator(to) | |
transmitted_key = Context( | |
{'hash_key': hash_key_example}) | |
# text_content = plaintext.render(d) | |
if controll == "comment_activation": | |
text_content = render_to_string('email/comment_content.html', | |
transmitted_key) | |
else: | |
text_content = render_to_string('email/email_content.html', | |
transmitted_key) | |
msg = EmailMultiAlternatives(subject, | |
text_content, | |
from_email, | |
[to]) | |
msg.send() | |
return HttpResponse(_("mail has been sent")) | |
else: | |
return HttpResponse(_("who do you want to send mail")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment