3π
You should setup from_email
parameter (as a kwarg or 3rd arg) with EmailMessage
call. Or define in settings.py:
DEFAULT_FROM_EMAIL = 'some.mail@inter.net'
This is taken as default if no from_email
is provided to EmailMessage
.
On a semi-related note, itβs probably a good idea to also define SERVER_EMAIL
in settings.py. This one is used with mail_admins
and mail_managers
by Django.
1π
All your settings are correct and complete, you just missed one thing at the end. You created a mail object and now email
is ready to be sent email object, but you need to actually send it with email.send()
. For more info and examples check Django documentation. Also, you can use send_mail
which automatically creates the email object and sends it.
from django.core.mail import send_mail
mail_title = 'Hello!'
message = 'Have you received this mail?'
email = 'admin@company.com'
recipients = 'someone@gmail.com'
send_mail(mail_title, message, email, [recipients])
- [Django]-Django- restrict users to access urls
- [Django]-Celery use wrong python version
- [Django]-Single Django Application, Multiple Instances
- [Django]-Why does Django with sqlite not insert unique constraint into the database schema?
0π
According to the following link https://docs.djangoproject.com/en/1.3/topics/email/, you should put email in brackets. That means, it should look like this:
from django.core.mail.import send_mail
mail_title = 'Hello!'
message = 'Have you received this mail?'
email = admin@company.com
recipients = 'someone@gmail.com'
send_mail(mail_title, message, email, [recipients])
- [Django]-Django .latest() values
- [Django]-Bootstrap Modal Forms Posting Twice Django
- [Django]-Is there a way to extract just the decimal value from django-money MoneyField without currency value?
- [Django]-Django ForeignKey null = true
- [Django]-Django: remotely access a PythonAnywhere MySQL database