forked from themartorana/python-postmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
25 lines (18 loc) · 910 Bytes
/
Copy pathforms.py
File metadata and controls
25 lines (18 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from django import forms
from django.conf import settings
from django.core.mail import send_mail
from django.utils.translation import ugettext_lazy
class EmailForm(forms.Form):
sender = forms.EmailField(max_length=100, initial=settings.POSTMARK_SENDER)
subject = forms.CharField(initial='test email')
body = forms.CharField(widget=forms.Textarea, initial='this is a test')
def save(self, fail_silently=False):
"""
Build and send the email message.
"""
send_mail(subject=unicode(ugettext_lazy(self.cleaned_data['subject'])),
message=self.cleaned_data['body'],
from_email=self.cleaned_data['sender'],
recipient_list=[addr.strip() for addr in self.cleaned_data['to'].split(',')],
fail_silently=fail_silently)