title: Django & Amazon SES SMTP. Cannot send email
body: <p>this is my settings.py : </p>
  
  <pre><code>EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
  EMAIL_PORT = '465'
  EMAIL_HOST_USER = config_data['EMAIL_HOST_USER']
  EMAIL_HOST_PASSWORD = config_data['EMAIL_HOST_PASSWORD']
  EMAIL_USE_SSL = True
  </code></pre>
  
  <p>I have verified the email addresses and have also generated SMTP credentials which I downloaded the credentials containing the IAM username, Smtp username, Smtp password. I used the smtp username for EMAIL_HOST_USER and smtp password for EMAIL_HOST_PASSWORD. </p>
  
  <p>In django, I sent an email with this line (admin@admin.com is replaced with a gmail account that is in the verified email list) : </p>
  
  <pre><code>send_mail("Subject", "content", "admin@admin.com", [email], fail_silently=False)
  </code></pre>
  
  <p>That did not work. Sending a test email from the SES console (select one of the email in verified emails and click send a test email button) works though. </p>
  
  <p>This <a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html" rel="nofollow">document</a> says that I can send email via command line with openssl command. So, i did ssh to the EC2 machine, and use : </p>
  
  <pre><code>openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.us-east-1.amazonaws.com:25
  </code></pre>
  
  <p>Notice that i used 25 here, when i used port 465, it outputed :</p>
  
  <pre><code>didn't found starttls in server response, try anyway...
  write:errno=32
  </code></pre>
  
  <p>So instead I tried port 25, It connected (250 OK) and then I typed :</p>
  
  <pre><code>AUTH LOGIN
  334 VXNlcm5hbWU6
  SMTP_USER
  334 UGFzc3dvcmQ6
  SMTP_PASSWORD
  </code></pre>
  
  <p>but it outputted : 535 Authentication Credentials Invalid. Could it be I used a wrong credentials? but I copy the username and password straight from the smtp user and password generation page.</p>
  
  <p>I also tried to attach AmazonSESFullAccess policy to all of the IAM users but nothing happened. </p>
  
  <p>I use the Django 1.8.2. Tried Django-ses but it did not work too (syntax error when running the tests, it does not support python 3?)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I changed the port to 587 and use USE_TLS True and now I can send_mail from django shell. I put the function in my app views.py : </p>
  
  <pre><code>def test_email(request):
    send_mail("title", "content", "abc@gmail.com", ["def@gmail.com"], fail_silently=False)
    return get_return_object(request, status_code=1)
  </code></pre>
  
  <p>and in urls.py I put this inside the urlpatterns : </p>
  
  <pre><code>url(r'^test_email/$', views.test_email, name="test_email"),
  </code></pre>
  
  <p>and when I visited the URL, nothing happens. I call the same function test_email from the shell and it works. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It turns out that I can also use port 465 and USE_SSL True and be able to send_mail from django shell. but still it does not work in views.py</p>