title: Error in sending emailusing smtplib in Django
body: <p>I am new to Django development. I have a contact message form which sends the data collected from the form to the recipient and saves the form in the database as well (sqlite).</p>
  
  <p>The code for views.py:</p>
  
  <pre><code>def contact(request):
      if request.method == 'POST':
          from django.core.mail import send_mail
          form = MessageForm(request.POST or None)
          if form.is_valid():
              name = form.cleaned_data['name']
              sender = form.cleaned_data['email']
              telephone = form.cleaned_data['telephone']
              subject = "Contact Us Form - Message"
  
              message = "From: " + name + " ( " + sender + " ) " + "Phone: " + telephone + "\n\n"
              message += form.cleaned_data['message']
  
              recipients = ['somdip@steanne.co.uk']
              save_it = form.save(commit=False)
              save_it.save()
              result = "Your message has been delivered. Thank you for contacting us! We will get in touch very soon.."
              try:
                  send_mail(subject, message, sender, recipients)
              except smtplib.SMTPException:
                  result = smtplib.SMTPException.message
              return render(request, "contactus.html", {"result": result, "style": "display: block", 'form': form})
          else:
              return render(request, "contactus.html", {"result": "Failed to send the message. Please validate your data. ",
                                                      "style": "display: block", 'form': form})
      else:
          form = MessageForm()
      return render_to_response('contactus.html', {'form': form},  context_instance=RequestContext(request))
  </code></pre>
  
  <p>the code in the forms.py:</p>
  
  <pre><code>class MessageForm(forms.ModelForm):
      class Meta:
          model = Message
          name = forms.CharField(label='Name *', max_length=120)
          email = forms.EmailField(label='Email *', max_length=120)
          telephone = forms.CharField(label='Telephone *', max_length=120)
          message = forms.CharField(label='Message *', max_length=2000, widget=forms.Textarea)
  </code></pre>
  
  <p>the code in the models.py:</p>
  
  <pre><code>class Message(models.Model):
      name = models.CharField(max_length=120, null=False, blank=False)
      email = models.EmailField(null=False,  blank=False)
      telephone = models.CharField(max_length=120, null=True, blank=True)
      message = models.TextField(max_length=2000, null=False, blank=False)
      timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
  
      def __unicode__(self):
          return smart_unicode(self.email)
  </code></pre>
  
  <p>in the settings.py I have also added:</p>
  
  <pre><code>#Email Sending for ContactForm
  EMAIL_HOST = 'smtp.gmail.com'
  EMAIL_PORT = 465
  EMAIL_HOST_USER = 'SECRET'
  EMAIL_HOST_PASSWORD = 'SECRET'
  EMAIL_USE_SSL = True
  </code></pre>
  
  <p>When I am pressing submit, it is giving me an exception error:</p>
  
  <blockquote>
    <p>attribute 'message' of 'exceptions.BaseException' objects</p>
  </blockquote>