I am using django-helpdesk for ticketing system.
its working fine but i am not able to send emails. i am testing this on my localhost.
while i submit a ticket, its getting submitted properly but submitter is not getting any email for newly created ticket.
i added new queue and provided details like E-Mail Address, E-Mail Box Type, E-Mail Hostname, E-Mail Port, Use SSL for E-Mail=False, E-Mail Username, E-Mail Password, IMAP Folder, E-Mail Check Interval properly.
but emails not getting sent.
then i removed all off above from queue and added settings like
QUEUE_EMAIL_BOX_TYPE = IMAP
QUEUE_EMAIL_BOX_SSL = True
QUEUE_EMAIL_BOX_HOST = 'smtp.gmail.com'
QUEUE_EMAIL_BOX_USER = 'email'
QUEUE_EMAIL_BOX_PASSWORD = 'pwd'
but still its not working.
am i missing any settings? please help me out.
QUEUE_EMAIL_BOX settings are not for sending emails, but for receiving them. Configuration for sending emails goes into standard email settings from django.
If you're using SMTP backend (this is default), configuration should be:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email'
EMAIL_HOST_PASSWORD = 'pwd'
EMAIL_USE_SSL = True
Related
I'm attempting to send email from a very simple Django app. The app is hosted on Heroku, and I have the Mailgun add-on installed. However, whenever I attempt to actually send an email using Mailgun, I get a SMTPServerDisconnected error, with the message Connection unexpectedly closed.
I've gone through almost every tutorial that I can find on the subject, and have still had no luck. My settings.py is exactly as described in the Heroku Mailgun documentation:
EMAIL_USE_TLS = True
EMAIL_HOST = os.environ.get('MAILGUN_SMTP_SERVER')
EMAIL_PORT = os.environ.get('MAILGUN_SMTP_PORT', '')
EMAIL_HOST_USER = os.environ.get('MAILGUN_SMTP_LOGIN', '')
EMAIL_HOST_PASSWORD = os.environ.get('MAILGUN_SMTP_PASSWORD', '')
The os environment variables referenced are managed by Heroku. When I've searched for similar problems, every other question has been using Port 465, however, my port is on 587, which shouldn't have this issue as far as I know.
Currently, I'm using the sandbox domain provided by Mailgun just to attempt to send a test email to a verified recipient email. The following code is used in my views.py to actually send the email, using the django django.core.mail.send_mail() function.
subject = "Thank you for RSVP-ing!"
message = f'Hello World!'
email_from = "mailgun#blannholley.com"
recipient_list = [request.POST.get('email'), ]
send_mail(subject, message, email_from, recipient_list, fail_silently=False)
Any help would be greatly appreciated, as this is my first time attempting to send email over SMTP, so I'm very lost here and feel like I've tried everything.
I know, there are plenty of similar questions about this, but none of them helped. When I set the EMAIL_BACKEND to django.core.mail.backends.console.EmailBackend, I do see the email when I trigger a 500. When I set EMAIL_BACKEND to django.core.mail.backends.smtp.EmailBackend, I don't receive the email.. but email manually sent using the send_mail function gets delivered just fine, so the email settings do work. I just don't understand this.
DEBUG = False
EMAIL_BACKEND = env("EMAIL_BACKEND")
EMAIL_HOST = "smtp.sendgrid.net"
EMAIL_HOST_USER = "apikey"
EMAIL_HOST_PASSWORD = env("SENDGRID_API_KEY")
EMAIL_PORT = 587
EMAIL_USE_TLS = True
SERVER_EMAIL = "{my email}"
ADMINS = [
("Kevin Renskers", "{my email}"),
]
MANAGERS = ADMINS
I don't have any custom LOGGING set, and like I said with django.core.mail.backends.console.EmailBackend I do see the email in my console.
So how can it be that I can send email using send_mail, yet errors are not sent to me using the exact same email settings? I've looked in my sendgrid account activity, and yeah they are not sent at all.
Thank you #michjnich for the suggestion to try to call mail-admins manually. When I did I got a clear error:
The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved.
Turns out I needed to change SERVER_EMAIL to another email address as configured in Sendgrid. The reason why my manual send_mail call worked fine, is because I gave it the correct from address there.
This is my SMTP configuration for my web page.
#SMTP (Simple Mail Transfert Protocole) Configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '*****************'
EMAIL_HOST_PASSWORD = '*************'
I created a web page using python and Django where the user has to login before.
When the user has forgotten his password, he has the possibility to reset his password.
to reset his password, the user has to enter his email then the link will be sent to his email provided during his registration.
*but when the user enters his email then clicks on send, instead to send the link into his email account, the link is redirect/ sent, to the "EMAIL_HOST_USER".*
Problem/Error
How should I configure the SMTP (Simple Mail Transfert Protocole) so that the user receives the link of the password reset into his email account provided during his registration?
please help me.
I'm currently building a contact form for my website in Django.
The only problem is that the email is not being sent when the form is submitted.
This is the code:
settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = "c******o#gmail.com"
EMAIL_HOST_PASSWORD = '****'
EMAIL_PORT = '587'
views.py:
sender_name = form.cleaned_data['nome_completo']
sender_email = form.cleaned_data['email']
message = "{0} has sent you a new message:\n\n{1}".format(sender_name, form.cleaned_data['messaggio'])
send_mail('New Enquiry', message, sender_email, ['c******o#gmail.com'])
My thought:
Since I'm in a virtualenv, when I submit the form, the terminal displays that it was successfully submitted, and gets me back the code right, maybe the email is not sent because of that, or maybe because I'm using a gmail account? Thanks!
Since you are using an SMTP server, why not use the following backend:
django.core.mail.backends.smtp.EmailBackend
Also, if you are using Gmail, make sure of the following:
Two-Factor authentication is enabled on account
You are using an app password.
You can find these on the security tab on your google account page:
https://myaccount.google.com/security
So the issue is with EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
This outputs emails to your console for debugging instead of actually sending emails. (See https://docs.djangoproject.com/en/3.1/topics/email/#console-backend)
Don't set EMAIL_BACKEND to anything for production as it defaults to django.core.mail.backends.smtp.EmailBackend. Then your EMAIL_HOST settings will take effect and the email should be sent out.
I'm working on a Django application.
I have set up all my required password reset views and corresponding pages.
In the final step I want to use Send Grid in my application to send the emails. I have the following setting s in my base.py file
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = 'codesniper99' # email id
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_PORT = 587
EMAIL_HOST_PASSWORD = '****' #password
EMAIL_USE_TLS = True
where **** is my password for the username codesniper99 on sendgrid.com
But when I use the password reset function I get locally generated email to my account. Like when i put email for reset as akhilvaid21#gmail.com
I get this:
when I push my code to my production server and not local host then it doesn't work and no email is sent. What am I doing wrong?
Also how do I change the name of webmaster#localhost???
Make sure you have set DEFAULT_FROM_EMAIL and SERVER_EMAIL in your settings.
Many email providers will only let you send email from verified email addresses. It looks as if Sendgrid might be blocking emails because Django is using the default webmaster#localhost for DEFAULT_FROM_EMAIL.