15👍
✅
Adjust your settings thus:
DEFAULT_FROM_EMAIL = 'workorbit@gmail.com'
SERVER_EMAIL = 'workorbit@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'workorbit@gmail.com'
EMAIL_HOST_PASSWORD = 'P@ssw0rd5'
Adjust your code:
from django.core.mail import EmailMessage
def send_email(request):
msg = EmailMessage('Request Callback',
'Here is the message.', to=['charl@byteorbit.com'])
msg.send()
return HttpResponseRedirect('/')
2👍
Google now provides a method to generate a password that you can use for applications that need to relay mail. its different from the password that you would use to login through webmail.
Sign in to Google and start using App Passwords. This allows you to use a 16 digit password to access google services including ability to send out email. Refer below
- Celery workers unable to connect to redis on docker instances
- Instead of Primary Key Send Different Field in Django REST Framework
- In the Django REST framework, how are the default permission classes combined with per-view(set) ones?
Source:stackexchange.com