Sending emails with SendGrid
This episode covers :-
1) How to send emails with SendGrid.
- Creating an account :-
Visit https://samuli.to/SendGrid and create an account:
Copy the base project:
Terminal
cp -fr 15-Base-Project 32-Sending-Emails
cd 32-Sending-Emails
source ../venv/bin/activate
Edit settings.py file and add the following configuration using the username and password you provided in the sign-in process:
mysite/settings.py
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'sendgrid_username'
EMAIL_HOST_PASSWORD = 'sendgrid_password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Test the mail in the interactive interpreter:
Interactive interpreter
python manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('Subject here', 'Here is the message.', 'admi\
n-mail@gmail.com', ['some-other-mail@gmail.com'], fail_sile\
ntly=False)
You should now receive the email in your inbox:
Summary :-
- Sending emails with SendGrid is just matter of creating an account with the service and adding the right configuration to the settings.py file.



No comments:
Post a Comment
If you have any doubts. Please let me know.