1

I am new to the emailing systems in web applications. I've built a Django app and I'd like to add a send email functionality. I bought a domain like 'mydomain.com' and I want to send emails from 'services@mydomain.com'. Is this possible using only mandrill?

EDIT

I have just the domain, there's no yet any email address created with my domain, this is the first time I am in charge of this and I'd like to know how to create emails addresses and use it to send messages via my django app and mandrill.


I have this working with a 'gmail' account, in my settings I have:

# EMAIL

DEFAULT_FROM_EMAIL = 'myaccount@gmail.com'
SERVER_EMAIL = 'myaccount@gmail.com'
EMAIL_HOST_USER = 'myaccount@gmail.com'
EMAIL_HOST_PASSWORD = 'myPassWord'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '587'
EMAIL_USE_TLS = True
Gocht
  • 9,924
  • 3
  • 42
  • 81
  • This isn't really a Django problem. This is really a duplicate of http://stackoverflow.com/questions/1332510/how-to-change-from-address-when-using-gmail-smtp-server and/or http://stackoverflow.com/questions/5431631/when-using-gmail-for-smtp-can-you-set-a-different-from-address – Mark Lavin Jul 01 '15 at 23:39
  • Mandrill -- like most outgoing email servers -- doesn't really care (much) who you send the emails "from". There's no need to create outgoing email addresses in Mandrill. – medmunds Jul 02 '15 at 01:28

2 Answers2

0

The code on the mandrill website for python has a very clear example of using it's SMTP authentication which works very well with Django:

EMAIL_HOST = 'smtp.mandrillapp.com'
EMAIL_HOST_USER = MANDRILL_USERNAME
EMAIL_HOST_PASSWORD = MANDRILL_PASSWORD
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102
  • Thanks for your answer, I edited the question. Does not exist any email created with my domain, is it possible to create them using mandrill? And is it possible to send emails with an account using another 'from'? – Gocht Jul 02 '15 at 01:26
  • I've tried this but does not work.. Do you hace any idea something is missing? – Gocht Jul 02 '15 at 15:13
  • Note that your EMAIL_HOST_PASSWORD needs to be a [Mandrill API key](https://mandrill.zendesk.com/hc/en-us/articles/205582197-Where-do-I-find-my-SMTP-credentials-) -- not your Mandrill account password. – medmunds Jul 02 '15 at 16:46
0

Djrill is a Mandrill email backend for Django. It uses the Mandrill HTTP API rather than SMTP, which can be helpful if you are running in an environment that blocks outgoing SMTP ports or you need to get extended status from Mandrill after sending a message.

Otherwise, using Mandrill's SMTP integration works just fine, as suggested in other answers.

medmunds
  • 5,950
  • 3
  • 28
  • 51
  • Thanks for your answer, I read about Djrill but I am using django.core.email in my project and I would like to change the code as less as possible. I edited the ask with some extra things. – Gocht Jul 02 '15 at 01:33
  • django.core.mail is designed to support [pluggable email backends](https://docs.djangoproject.com/en/1.8/topics/email/#email-backends). Djrill is an implementation of a pluggable backend that uses Mandrill for sending. So it "just works" with all of the standard django.core.mail [send functions](https://docs.djangoproject.com/en/1.8/topics/email/#send-mail), [EmailMessage](https://docs.djangoproject.com/en/1.8/topics/email/#the-emailmessage-class) objects, and other django.core.mail features. – medmunds Jul 02 '15 at 16:39
  • Thanks for your answer, I did it using Djrill and following its configuration steps to work with mandrill smpt. Do you have any idea about how to change the name in the inbox? for example, I send an email from my personal account via my account in mandrill and in the inbox (next to the subject) appear my email, not my name, is it possible show a custom text there? – Gocht Jul 02 '15 at 17:48
  • I think you're looking for the `from_email` parameter to the various Django send-mail functions. You can give a display name and an email address: e.g., `from_email="Support Team "`. This isn't Djrill-specific -- it works with most Django email backends. See [Django sending docs](https://docs.djangoproject.com/en/1.8/topics/email/#django.core.mail.send_mail) and [Djrill sending docs](http://djrill.readthedocs.org/en/v1.4/usage/sending_mail/). (Also [example sending code](http://djrill.readthedocs.org/en/v1.4/quickstart/) in step 3.) – medmunds Jul 02 '15 at 18:08
  • I found it [here](http://djrill.readthedocs.org/en/latest/usage/sending_mail/#django-email-support) in Djrill documentation. Thanks again. – Gocht Jul 02 '15 at 19:05