Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Email in Django without SMTP server. Like php mail() function does

As far as I read, Django only supports sending mails using SMTP.

I would like to send Emails from my script in Django, but do not want to setup SMTP server (it's too complex for me, I'm a linux newbie).

Is it possible, to send mails in Django in the same way like I do it in PHP, without providing SMTP login, password and etc?

like image 729
Silver Light Avatar asked Feb 25 '10 15:02

Silver Light


Video Answer


4 Answers

PHP uses sendmail on UNIX system to send emails. I guess at some point when you set up the system, this is, sendmail is configured.

There is an API to sendmail for Python, maybe it helps you. But there is a SMTP server involved in any case ;)

like image 140
Felix Kling Avatar answered Sep 22 '22 17:09

Felix Kling


Postfix and Exim were built to deal with all of the problems associated with forwarding email from your host to the rest of the world. Your app speaks SMTP to them, and they turn around and speak SMTP with the destination. But they're very, very good at it.

There is nothing stopping you from doing a DNS lookup for the MX records of the email address you're sending to and connecting straight to that server and speaking SMTP to it. Nothing except that nagging voice that should be asking you "Is this really easier than apt-get install exim4?"

like image 42
Don Spaulding Avatar answered Sep 21 '22 17:09

Don Spaulding


So how does PHP do it? By magic?

If you don't have an SMTP server, sign up for a GMail account and use that.

like image 26
Daniel Roseman Avatar answered Sep 20 '22 17:09

Daniel Roseman


Your hosting provider might have set up the host and any possible login credentials for all the PHP pages on their machines. This would make it seem like none are required. Your hosting provider should be more than happy to give you the information. Try searching for SMTP in their FAQ, forum, and any welcome emails they sent. If your search does not turn anything up, ask them directly.

Once you have the information, you will want to add it to your settings.py file using these email settings:

# *** settings.py ***
#EMAIL_HOST = 'host here'
#EMAIL_PORT = 587
#EMAIL_HOST_USER = 'your user here'
#EMAIL_HOST_PASSWORD = 'your password'
#EMAIL_USE_TLS = True

Uncomment and use as many of these settings as you need.

like image 45
istruble Avatar answered Sep 18 '22 17:09

istruble