30
loading...
This website collects cookies to deliver better user experience
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your gmail account'
EMAIL_HOST_PASSWORD = 'your account’s password'
EMAIL_USE_SSL = False
Note: Your password is visible here so before deploying it encrypt your password or place in a file or server, where only have access.
from django.core.mail import send_mail
from django.conf import settings
def mail(request):
...
subject = 'your subject'
message = 'your message'
email_from = settings.EMAIL_HOST_USER
recipient_list = ['receiver's mail address', ]
return render(request,'some_page.html')
urlpatterns = [
path('mail', views.mail, name ='mail'),
]