Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am writing django application and trying to send email using it I have "Access to low security app" in gmail enabled and django setting are given below which I think are right. but I am still getting error as mentioned it title. I dont know the problem but I know I am not getting logged in to send email.
Edit 1: I have made two changes first in settings.py and second in views.py in views.py I replaced email entered by user to mine(syedfaizan824@gmail.com) and settings.py DEFAULT_EMAIL_FROM is changed form testing@example.com to syedfaizan824@gmail.com
searched on internet and find out that gmail does not allow low security app to login by default but I turned it off in setting of gmail. find out that my email backend was wrong so made it right. fail silently is False.
settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = 'syedfaizan824@gmail.com'
EMAIL_HOST_USER = 'syedfaizan824@gmail.com'
EMAIL_HOST_PASSWORD = '******'
views.py
def post(self, request, *args, **kwargs):
form = contact(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
phone = form.cleaned_data['phone']
organization = form.cleaned_data['organization']
message = form.cleaned_data['message']
ref_code = form.cleaned_data['ref_code']
plan = form.cleaned_data['plan']
message = message + ref_code
send_mail(
'from website' + name + " " + organization,
message,
'syedfaizan824@gmail.com',
['syedfaizan824@gmail.com'],
fail_silently=False,
print("sent")
else:
#print('something is wrong with forms!')
return render(request, self.template_name, self.context)
Error message is ConnectionRefusedError WinError[10061]. and statement of error is : No connection could be made because the target machine actively refused it. which means I am not getting logged in.
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.