Accueil
[auf_framonde.git] / project / contact / forms.py
1 from django import forms
2 from django.core.mail import EmailMessage
3 from django.template.loader import render_to_string
4
5 class ContactForm(forms.Form):
6 email = forms.EmailField()
7 subject = forms.CharField()
8 content = forms.CharField(widget=forms.Textarea())
9
10 def send(self, site_email):
11 email_message = EmailMessage(
12 self.cleaned_data['subject'],
13 render_to_string("email.txt", {
14 'data': self.cleaned_data,
15 }),
16 site_email,
17 [site_email],
18 headers = {
19 'Reply-To': self.cleaned_data['email']
20 },)
21 email_message.send(fail_silently=True)
22