I suddenly started getting the above error message and had absolutely no reason why. I speculated that my database was corrupt and deleted it and started again. When that failed I reviewed my firewall sections. I turned them all off and the problem still persisted.
I was following a Udemy tutorial and copying and pasting the code from Github. We had added code to send confirmation emails when the user signs up. When I was watching the videos I had missed this detail. I had no idea we were now sending registration emails. And I was getting the issue because I could not send confirmation emails when using LOCALHOST.
If you get this error and like me have no idea why you are receiving it. Then do CTRL + Shift + F (Find) and see if you can spot any mention of emails.
I added in an if statement that now prevents the code attempting to send emails when I am running my site on LOCALHOST.
def post_save_user_create_reciever(sender, instance, created, *args, **kwargs):
if created:
obj = EmailActivation.objects.create(user=instance, email=instance.email)
EMAIL_PORT = getattr(settings, 'EMAIL_PORT', 0)
if EMAIL_PORT == 587:
obj.send_activation()
If you are attempting to send emails, then you will need to modify your settings file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.