Having followed the...
 
Notifications
Clear all

Having followed the tutorial till this stage, I am stuck at the SEND VERIFICATION EMAIL. Even looking at the project git repository, I am still receiving error messages

3 Posts
2 Users
0 Reactions
13 Views
0
Topic starter

/// utils.py ///

# accounts/utils.py
from django.contrib.sites.shortcuts import get_current_site
from django.template.loader import render_to_string
from django.utils.http import urlsafe_base64_encode
from django.utils.encoding import force_bytes
from django.contrib.auth.tokens import default_token_generator
from django.core.mail import EmailMessage

def detectUser(user):
if user.role == 1:
    redirectUrl = 'vendorDashboard'
return redirectUrl
elif user.role == 2:
    redirectUrl = 'custDashboard'
return redirectUrl
elif user.role == Noneand user.is_superadmin:
    redirectUrl = '/admin'
return redirectUrl

def send_verification_email(request, user):
  current_site = get_current_site(request)
  mail_subject = 'Please activate your account'
  message = render_to_string('accounts/emails/account_verification_email.html', {
       'user': user,
       'domain': current_site,
       'uid': urlsafe_base64_encode(force_bytes(user.pk)),
       'token': default_token_generator.make_token(user),
  })
  to_email = user.email
  mail = EmailMessage(mail_subject, message, to=[to_email])  
  mail.send()
 
 
///Error messages from browser//
 
C:\Users\Yanga\Desktop\GAAS\accounts\views.py, line 58, in registerUser
  1.       user = User.objects.create_user(first_name=first_name, last_name=last_name, username=username, email=email, password=password)
  2.       user.role = User.CUSTOMER
  3.       user.save()
  4.       
  5.       #Send verification email
  6.       mail_subject = 'Please activate your account'
  7.       email_template = 'accounts/emails/account_verification_email.html'
  1.       send_verification_email(request, user)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  1.       messages.success(request, "Your account has been registered successfully!")
  2.       return redirect('registerUser')
  3.     else:
  4.       print('invalid form')
  5.       print(form.errors)
  6.   else:   


 

C:\Users\Yanga\Desktop\GAAS\accounts\utils.py, line 32, in send_verification_email

  1.     'user': user,
  2.     'domain': current_site,
  3.     'uid': urlsafe_base64_encode(force_bytes(user.pk)),
  4.     'token': default_token_generator.make_token(user),
  5.   })
  6.   to_email = user.email
  7.   mail = EmailMessage(mail_subject, message, to=[to_email])  
  1.   mail.send()
    
This topic was modified 5 days ago by Ibrahim Salami
3 Answers
0
Topic starter

https://github.com/hizeetech/gaas.git

0

Hi Ibrahim Salami ,

The issue you are facing occurs when your SMTP configuration is incorrect. Please check your SMTP settings to ensure they are correct. Additionally, the GitHub repository link you provided is incorrect.

If you are unable to fix the issue, please provide a screenshot of your SMTP configuration and share a ZIP file link to your project so we can assist you in resolving the problem.

0
Topic starter

An invitation has been sent to you as collaborator on the repository.
Thanks

Share: