Django project settings.py includes the following:
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "you.cant.see.me@gmail.com"
EMAIL_HOST_PASSWORD = "thug_life"
EMAIL_PORT = 587
EMAIL_USE_TLS = True
My Application's views.py contains the following
def send_classic_email(request):
    from django.core.mail import send_mail
    send_mail(
        subject = "Tale of two cities",
        from_email = "Charles Dickens <you.cant.see.me@gmail.com>",
        recipient_list = ["someone@example.com"],
        message = "There were 2 cities",
        html_message = "<p>There were 2 cities</p>",
        fail_silently = False,
    )
    print "Absolutely Perfectly Done"
Tried from localhost. Got SMTPAuthenticationError in return:
SMTPAuthenticationError at /send_classic_email/
(534, '1.3.95 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=fsadjSADJH\n1.3.95 
fjkshFHAKSHkdfshkfkhj-sfjdhFsadASDA_\n1.3.95 
dasdASDADas-aDas-hfhjsadASDSAhjjhd\n1.3.95 
ADSaSADkja_adhjkADKjhads-ASADS_SDAKjadAKJhsADS-k\n1.3.95 
sadhkjADSAKJSDJAlkjdaA> Please log in via your web browser and\n1.3.95 
then try again.\n1.3.95  
Learn more at\n1.3.95  
https://support.google.com/mail/answer/78754 dkahASDASlkjdas.25 - gsmtp')
Then visited https://www.google.com/settings/security/lesssecureapps and enabled the less secure app setting. 
After that, tried once again from localhost. Got this:
Absolutely Perfectly Done
Deployed this very code on AWS EC2. Tried from EC2. Got the same SMTPAuthenticationError again:
SMTPAuthenticationError at /send_classic_email/
(534, '1.3.95 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=fsadjSADJH\n1.3.95 
fjkshFHAKSHkdfshkfkhj-sfjdhFsadASDA_\n1.3.95 
dasdASDADas-aDas-hfhjsadASDSAhjjhd\n1.3.95 
ADSaSADkja_adhjkADKjhads-ASADS_SDAKjadAKJhsADS-k\n1.3.95 
sadhkjADSAKJSDJAlkjdaA> Please log in via your web browser and\n1.3.95 
then try again.\n1.3.95  
Learn more at\n1.3.95  
https://support.google.com/mail/answer/78754 dkahASDASlkjdas.25 - gsmtp')
Went to EC2 security groups:
- Inbound rules for SMTP port from ALL sources are enabled.
- Outbound rules for ALL traffic for ALL ports over ALL protocols to ALL destinations are enabled.
Still getting the same SMTPAuthenticationError. 
Why is it working fine from localhost and not from EC2 instance?
Running Django 1.8.0 on Python 2.7.6 in Ubuntu 14.04.3 LTS
 
     
     
    