Django - Sending emails using class based view
<p>I have been making a website containing a listview and formview. I have a form.py which looks like this : </p>

<pre><code>from django import forms

class ContactForm(forms.Form):
    name = forms.CharField(required=True)                   
    email = forms.EmailField(required=True)
    message = forms.CharField(required=True)
</code></pre>

<p>and the views.py : </p>

<pre><code>from django.shortcuts import render
from .forms import ContactForm
from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from blog.models import Post
from django.core.mail import EmailMessage

class PostListAndFormView(FormMixin,ListView):
    queryset = Post.objects.all().order_by("-date")[:2]
    template_name = 'personal/index.html'
    form_class = ContactForm
    success_url = 'personal/index.html'
</code></pre>

<p>This view also deals with a Listview functionality which you can ignore. </p>

<p>My HTML template is:</p>

<pre><code>&lt;form action="/" method="post"&gt;
{% csrf_token %}
{{ form }}
&lt;input type="submit" value="SEND MESSAGE" /&gt;   
&lt;/form&gt;
</code></pre>

<p>Finally urls.py :</p>

<pre><code>from django.conf.urls import url,include
from . import views
from homepage.views import PostListAndFormView

urlpatterns = [
    url(r'^$', PostListAndFormView.as_view(), name='PostListAndFormView'),
]
</code></pre>

<p>What I want to do here is take the data from the form and send an email to my address with the entered data. Someone help me do this. </p>