Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django email backend with local smtp

I want send email from django application.

I want send an email to my mail id from other username without authentication. Just i used smtp server for the authenticated mail.In the django mail api How it is supposed to send an mail with the local smtp?

like image 309
Nava Avatar asked May 16 '12 19:05

Nava


People also ask

How do I send an email using django?

Sending Emails with the Django ShellWe import the Django send_mail function. Then we import the settings object which contains all the global settings and the per-site settings (those inside the settings.py file). Finally, we pass all the needed arguments to the send_mail function.

How do I send an email notification in django REST framework?

Inside of the “send_mail.py”, create a function that takes in the following arguments. def send_mail(html,text='Email_body',subject='Hello word',from_email='',to_emails=[]): The next step would be to make sure that the “to_emails” argument is always a “list of emails” and not a string or any other data type.

How do I use django to send an email from Gmail?

send_mail() method is imported from django. The send_mail() method handles the transmission of Emails. There are some important parameters of send_mail(), which we have defined here: subject: Contains the subject part of the Email. message: Contains the Email body.


1 Answers

As stated on the docs: https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs you need to:

  • On your settings.py define the following:

    EMAIL_HOST = 'localhost' EMAIL_PORT = 1025

  • Then, in another shell run the following command:

    python -m smtpd -n -c DebuggingServer localhost:1025

That will run a dummy SMTP server, that actually will not send any email but you'll be able to see the output and check if that's correct. If you want to actually send your emails during development, you will need to install a SMTP server like sendmail and use that in your configuration.

like image 68
pyriku Avatar answered Sep 22 '22 14:09

pyriku