Sending email from Django Mezzanine running on Heroku - django

I am using rackspace email and having problem sending email via Mezzanine(1.4.10) form page.
This is my settings:
EMAIL_HOST = 'secure.emailsrvr.com'
EMAIL_PORT = 465 # other ports also tried
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'info#example.com'
EMAIL_HOST_PASSWORD = 'secret'
This is Rackspace documentation:
http://www.rackspace.com/apps/support/portal/1088
But I can send email from the console like this:
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'from#example.com',
['to#example.com'], fail_silently=False)
It return 1 and I actually got the email. If I do that from Mezzanine, I assumed it also return 1 according the redirect URL after the email was sent, but I don't get the email.

In addition to the settings mentioned in the Django documentation, try setting DEFAULT_FROM_EMAIL. You will probably want to use the same value as EMAIL_HOST_USER.

Related

Django send_mail error using smtp.domain.com (smtplib.SMTPHeloError: (501, b'Syntactically invalid HELO argument(s)'))

I have a problem when sending an email using Django as the email I'm trying to send from is hosted on domain.com, I've tried to send from Gmail and it worked fine but when I use the configuration of domain.com it gives me this error: smtplib.SMTPHeloError: (501, b'Syntactically invalid HELO argument(s)')
what I understand is that it is related to the host name, but I don't know what to do to fix that error and can I use a different hostname for domain.com that works. below is the configuration in setting.py and send_mail function:
setting.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.domain.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'Name#emailFrom.com'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_HOST_PASSWORD = "********"
send_mail function:
send_mail(
'HR Request',
'your request is being processed',
'Name#emailFrom.com',
['Name#emailTo.com'],
fail_silently=False,
)
return HttpResponse('Mail sent')

send_mail works locally but not on production hosting

The following works locally but as I deployed it to production hosting at Digital Ocean, the email is not sending as I test on shell command (python manage.py shell) like below. The send_mail line just got stuck there and am getting error: [Errno 101] Network is unreachable after few minutes. How can I capture the error on the email sending? Please advise how can I troubleshoot this issue.
from django.core.mail import send_mail
send_mail('test email', 'hello world', 'xxxx#gmail.com', ['xxxx#gmail.com'],fail_silently=False)
# Email settings
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'xxxx' #my gmail password
EMAIL_HOST_USER = 'xxxx#gmail.com' #my gmail username
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
Your Django app settings look correct but you should also head over to https://accounts.google.com/DisplayUnlockCaptcha and make sure you enable access to lower security applications.
Also consider creating an application-specific password if you're using Two-Factor-Authentication.

Django send_mail not working with gmail

I have been trying everything to get django to send a test email, with no success. My test email is being sent from a python anywhere dev site. Here is my views ajax:
def ajaxLearning(request):
if request.method == 'GET':
from django.core.mail import send_mail
send_mail('Put your Email subject here', 'Put your Email message here.',
'myspamgoes#gmail.com', ['someemail#yahoo.com'],
fail_silently=False)
return HttpResponse("end");
else:
pass
And here is my settings.py:
DEFAULT_FROM_EMAIL = 'myspamgoes#gmail.com'
SERVER_EMAIL = 'myspamgoes#gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'myspamgoes#gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
At this point I feel as if I am making some higher level mistake such as, using the wrong version of django, failing to install something crucial, or doing something wrong on the gmail side. For the password, which I changed earlier today, I am using the one that I would use to normally sign in to my account. Thank you for taking the time to read my question!
Change in settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER = 'myemailhere#gmail.com'
EMAIL_HOST_PASSWORD = '**********'
DEFAULT_FROM_EMAIL = 'myemailhere#gmail.com'
EMAIL_USE_TLS = True

Django send_mail not working - No email delivered

When the view that sends the email is used nothing happens, i then entered send_mail(...) into the python shell and it returned 1 but i didn't receive any emails.
This is my settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'senderaddress#gmail.com'
EMAIL_HOST_PASSWORD = 'Password1234!'
EMAIL_USE_TLS = True
This is the view:
def send_email(request):
send_mail('Request Callback', 'Here is the message.', 'senderaddress#gmail.com',
['recipientaddress#gmail.com'], fail_silently=False)
return HttpResponseRedirect('/')
Adjust your settings thus:
DEFAULT_FROM_EMAIL = 'workorbit#gmail.com'
SERVER_EMAIL = 'workorbit#gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'workorbit#gmail.com'
EMAIL_HOST_PASSWORD = 'P#ssw0rd5'
Adjust your code:
from django.core.mail import EmailMessage
def send_email(request):
msg = EmailMessage('Request Callback',
'Here is the message.', to=['charl#byteorbit.com'])
msg.send()
return HttpResponseRedirect('/')
Google now provides a method to generate a password that you can use for applications that need to relay mail. its different from the password that you would use to login through webmail.
Sign in to Google and start using App Passwords. This allows you to use a 16 digit password to access google services including ability to send out email. Refer below
https://support.google.com/accounts/answer/185833?hl=en

Send emails in a django development environment on OS X leopard

Hay, i was wondering how i would go about setting up django so that i can send emails from a standard Leopard installation.
In php i just use mail() and it sends the mail for me.
Thanks
From the docs:
Mail is sent using the SMTP host and port specified in the EMAIL_HOST and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD settings, if set, are used to authenticate to the SMTP server, and the EMAIL_USE_TLS setting controls whether a secure connection is used.
So set your EMAIL_HOST to a friendly SMTP server which will relay mail for you, and away you go.
Again, from the docs:
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'from#example.com',
['to#example.com'], fail_silently=False)