115π
Looks like you are trying to send a mail (send_mail()
) and your mail settings in your settings.py
are not correct.
You should check the docs for sending emails.
For debugging purposes you could setup a local smtpserver with this command:
python -m smtpd -n -c DebuggingServer localhost:1025
and adjust your mail settings accordingly:
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
This is documented here: Testing e-mail sending
As an alternative to starting a dedicated debugging server you could use the console.EmailBackend
which was added to Django recently.
33π
For Development and Testing:
In Django 1.6+ we can just add this line in settings.py
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
This will display the mail on the console for Easy Verification.
Note:
Mail will not be sent to the specified recipient in Msg.Its just for Development and Testing.
For that you need to configure SMTP server which is given in the Doc.
For Reference: Django Documentation for Sending Email
- [Django]-How to filter objects for count annotation in Django?
- [Django]-Django β No such table: main.auth_user__old
- [Django]-Unsupported operand type(s) for *: 'float' and 'Decimal'
13π
Install postfix package on your server and it works. If is ubuntu, try it:
sudo apt-get install postfix
In your settings, put:
EMAIL_HOST = 'localhost'
- [Django]-How to update fields in a model without creating a new record in django?
- [Django]-Django β Reverse for '' not found. '' is not a valid view function or pattern name
- [Django]-Create if doesn't exist
7π
We recently moved away from the Python debugging email server to use a program called Mailcatcher. Mailcatcher runs as a daemon to intercept all of your test email messages to port 1025, and is integrated with a web server so that you can then view the intercepted emails from a browser. Advantages
- you can view test emails as HTML if needed
- central management of all test emails β they stay around until you clear them
- view test emails from any browser, instead of scrolling through terminal window
You can read more and download it here:
http://rubygems.org/gems/mailcatcher
If you donβt like Ruby, a co-worker of mine has ported the functionality of Mailcatcher to node.js β check out MailDev here: http://djfarrelly.github.io/MailDev/
- [Django]-Django test RequestFactory vs Client
- [Django]-Django TemplateDoesNotExist?
- [Django]-ForeignKey to abstract class (generic relations)
5π
additionally the following will help:
put the following minimal settings in the settings.py or local_settings.py file on your server.
EMAIL_HOST = 'localhost'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
instead of using smtp.gmail.com which imposes lot many limitations, you can have your own mail server.
you can do it by installing your own mailserver:
sudo apt-get install sendmail
- [Django]-Django β FileField check if None
- [Django]-How to limit the maximum value of a numeric field in a Django model?
- [Django]-How does Django Know the Order to Render Form Fields?
4π
I also run into this error. Instead of using gmail, I decided to setup my own mailserver using postfix. See my reasons here.
To setup postfix on Ubuntu 12.04:
sudo apt-get install postfix
Then, copy the config file to /etc/postfix/:
cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
Add the following lines to main.cf:
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mydestination = localhost
Reload the config file:
/etc/init.d/postfix reload
To test and see if postfix is working:
telnet localhost 25
Then enter the following line by line:
mail from: whatever@whatever.com
rcpt to: your_real_email_addr@blah.com
data (press enter)
type whatever content you feel like to type
. (put an extra period on the last line and then press enter again)
If it works, you should see something like this:
250 2.0.0 Ok: queued as CC732427AE
Next, put the following line in your Djangoβs settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'Server <server@whatever.com>'
To test if Django can send email via postfix, open Django shell:
./manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('Subject here', 'Here is the message.', 'from@example.com',
['to@example.com'], fail_silently=False)
Check your spam inbox and you should see the email above shown.
- [Django]-How to make an auto-filled and auto-incrementing field in django admin
- [Django]-Django Rest Framework: turn on pagination on a ViewSet (like ModelViewSet pagination)
- [Django]-ValueError: Dependency on app with no migrations: customuser
1π
installing postfix did it for me.
There seemed to be no answer here that was suitably upvoted, so this page can be a bit confusing. Notice in the documentation: https://docs.djangoproject.com/en/1.3/ref/settings/#std:setting-EMAIL_HOST
the parameters settings.py have default values.
When I installed postfix it fixed the problem, locally at least.
Hope this helps another confused soul!
- [Django]-IOS app with Django
- [Django]-How to change a django QueryDict to Python Dict?
- [Django]-Creating email templates with Django
0π
EMailDump is usable and useful local server smtp, easy installation, this developed in python
https://github.com/ThiefMaster/maildump
- [Django]-'EntryPoints' object has no attribute 'get' β Digital ocean
- [Django]-How to add url parameters to Django template url tag?
- [Django]-How to use MySQLdb with Python and Django in OSX 10.6?