MCPcopy Create free account
hub / github.com/codingjoe/django-mail-auth / send_mail

Method send_mail

mailauth/forms.py:133–151  ·  view source on GitHub ↗

Send a django.core.mail.EmailMultiAlternatives to `to_email`.

(self, to_email, context)

Source from the content-addressed store, hash-verified

131 self.send_mail(email, context)
132
133 def send_mail(self, to_email, context):
134 """Send a django.core.mail.EmailMultiAlternatives to `to_email`."""
135 subject = loader.render_to_string(self.subject_template_name, context)
136 # Email subject *must not* contain newlines
137 subject = "".join(subject.splitlines())
138 body = loader.render_to_string(self.email_template_name, context)
139
140 email_message = EmailMultiAlternatives(
141 subject, body, self.from_email, [to_email]
142 )
143 try:
144 template = loader.get_template(self.html_email_template_name)
145 except TemplateDoesNotExist:
146 pass
147 else:
148 html_email = template.render(context, self.request)
149 email_message.attach_alternative(html_email, "text/html")
150
151 email_message.send()

Callers 2

saveMethod · 0.95

Calls

no outgoing calls

Tested by 1