views:

458

answers:

4

Hello!

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?

+2  A: 

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.

Daniel Roseman
I'm not sure how PHP does it, but I didn't specify no SMTP auth settings anywhere, when installing PHP. I considered Gmail SMTP, but then my mail must be only from my gmail account. I would like to use other emails in "from" field.
Silver Light
why not try an STMP gateway like AuthSMTP then?
stevejalim
+2  A: 

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 ;)

Felix Kling
Thanks that was what I needed. Here's one more example that helped: http://www.yak.net/fqa/84.html
Silver Light
+1  A: 

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.

istruble
I have my own server, so hosting provider can't help me. Thank you for reply.
Silver Light
A: 

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?"

Don Spaulding
apt-get install is a thing that I can handle, but SASL configuration frightens me. It's seems to hard for such a trivial task...
Silver Light
I'm not sure why you consider SASL necessary. Configure Postfix or Exim to only accept connections from trusted IPs (ideally just 127.0.0.1) and do without authentication completely.
Don Spaulding