1from django.core.mail import send_mail
2
3if form.is_valid():
4 subject = form.cleaned_data['subject']
5 message = form.cleaned_data['message']
6 sender = form.cleaned_data['sender']
7 cc_myself = form.cleaned_data['cc_myself']
8
9 recipients = ['info@example.com']
10 if cc_myself:
11 recipients.append(sender)
12
13 send_mail(subject, message, sender, recipients)
14 return HttpResponseRedirect('/thanks/')
15
1from django import forms
2
3class NameForm(forms.Form):
4 your_name = forms.CharField(label='Your name', max_length=100)
5