Django: password reset not sending any email - django

I am trying to implement the 'password-reset' functionality using django. I set up my urls:
path('account/reset_password/', auth_views.PasswordResetView.as_view(), name='reset_password'),
path('account/reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
path('account/reset/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('account/reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
and the Settings.py:
EMAIL_FILE_PATH = f"{BASE_DIR}/sent_emails"
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_PORT = '587'
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'someaccount#outlook.com'
DEAFULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = 'somepassword'
No emails are sent from the host email. I tried using console.EmailBackend and an email is indeed written, a working reset link is provided in the email. Everything works besides sending the email to the receiver address. Is there something wrong with the settings?

Related

How do I use allauth with out unexpectedly closed

I was trying to add ALLAUTH to my django app
Settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "smtp.gmail.com"
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = "xxxxxx#gmail.com"
EMAIL_HOST_PASSWORD = "xxxxxxxx"
urls.py
path("accounts/user/<pk>", views.OtherProfileView.as_view(), name='profile_view'),
path("password/change/", PasswordChangeView.as_view(
template_name='accounts/password_change.html',
success_url="/",
form_class=PasswordChangeForm),
name='password_change'),
path("passoword/reset/", views.CustomPasswordReset.as_view(),
name='password_reset'),
path("password/reset/confirm/<uidb64>/<token>/",
PasswordResetConfirmView.as_view(
template_name='accounts/password_reset_confirm.html'),
name='password_reset_confirm')
I expected email will recieve me email reset to my mai`

How to configure Django Email Back-end Settings to send email via RoundCube Webmail in production

During development, I have been using Gmail SMTP to send emails from my Django app. The Gmail settings are (settings.py):
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'xxxx#gmail.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxx'
However, during production, I need to change to RoundCube webmail client to allow my project to use a custom email address that matches the domain name. I have tried the following settings and many others but none of them is working. I know this is simple, but this is my first project and I don't know whether there is something I am missing.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mydomain.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 465
EMAIL_HOST_USER = 'accounts#mydomain.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxx'

Django - EmailMessage working in shell but dont working in view with same data

I want to send mail after form valid. So i using EmailMessage class .
My code like this.
EmailMessage(subject='ddd', body='ff2', from_email='test#gmail.com', to=['test#gmail.com'], reply_to=['test#gmail.com'], headers={}).send()
This code work very well in django shell. But not work when i use to in django views.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'test#gmail.com'
EMAIL_HOST_PASSWORD = password_create_with_google_app
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

how to display company name instead of email address while sending password reset email in django

how to display name instead of email address.I am using PasswordResetView and i have configured this email in settings.py.When i just use only email address in EMAIL_HOST_USER then it works fine but after i changed like this to display name then it is not working.How can i solve this
settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = "CompanyName <company#gmail.com>"
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = '587'
urls.py
path('password-reset/',
auth_views.PasswordResetView.as_view(template_name='students/password_reset.html',
email_template_name='students/password_reset_email.html',
success_url=reverse_lazy('students:password_reset_done')),
name='password_reset'),
path('password-reset/done/',
auth_views.PasswordResetDoneView.as_view(template_name='students/password_reset_done.html'),
name='password_reset_done'),
path('password-reset-confirm/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(template_name='students/password_reset_confirm.html',
success_url=reverse_lazy('students:password_reset_complete')
), name='password_reset_confirm'),
path('password-reset-complete/',
auth_views.PasswordResetCompleteView.as_view(template_name='students/password_reset_complete.html'),
name='password_reset_complete'),
pass the from_email argument in the as_view() from the url config itself.
path('password-reset/',
auth_views.PasswordResetView.as_view(template_name='students/password_reset.html',
email_template_name='students/password_reset_email.html',
success_url=reverse_lazy('students:password_reset_done',),
from_email="CompanyName <company#gmail.com>"),
name='password_reset'),
The EMAIL_HOST_USER settings has no role in this context. So, change it back to the original state.

What is EMAIL_PORT for protonmail.com mail service?

I tried to use https://protonmail.com email service for my django app to send notification emails. I googled and found that protonmail SMTPis 1026 and protonmail IMAP is 1143.
When I use gmail service it works fine.
My settings.py
EMAIL_HOST = 'smtp.protonmail.com'
EMAIL_HOST_USER = 'username#protonmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 1026
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'apps', 'emails')
The ProtonMail Bridge says the email port should be 1025. I attached a screenshot of my SMTP settings.