How to send email via Django?
To test whether emails are being sent through Django terminal, do the following checks.
In settings.py
- EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
- DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
Run in interactive mode from Visual Studio Terminal
- python manage.py shell
Import the EmailMessage module
- from django.core.mail import EmailMessage
Send the email with below command.
- email = EmailMessage('Email Subject', 'This is for email Body', to=['xxxxxxxxxxxxx@xxxxxx.com'])
- email.send()
If the above steps works successfully then your email account is configured to send emails.
Comments
Post a Comment