How to send email validations through Django?

so, I’m trying to make a function in my django project that sends a confirmation key through email for the user

so I tried to do this:

views.py

def createuser(request):
    form = MyUserCreationForm()

    if request.method == 'POST':
        form = MyUserCreationForm(request.POST)
        if form.is_valid():
            return redirect('confirm-email')
        else:
            messages.error(request,'An error occured during your registration')
    context = {'form':form}
    return render(request, 'signup.html', context)

def confirmemail(request):
    form = MyUserCreationForm() 
    if request.method == 'POST':
        form = MyUserCreationForm(request.POST) 
        if form.is_valid():
            email = form.cleaned_data['email']
            user = User.objects.get(email=email)
            subject = 'Confirm your email' 
            from_email = 'myemail@gmail.com'
            email = [email]
            recipient_list = email
            return send_mail(subject, 'Use %s to confirm your email.' % request.user.confirmation_key, from_email, recipient_list)
        user.confirm_email(user.confirmation_key)
    
        
        if user.is_confirmed == True:
            user = form.save(commit=False)
            user.username = request.user.username.lower()
            user.save()
            login(request,user)
            return redirect('home')
    context = {'form':form}
    return render(request, 'emailconfirm.html', context)

models.py

from django.db import models
from django.contrib.auth.models import AbstractUser
from simple_email_confirmation.models import SimpleEmailConfirmationUserMixin
class User(SimpleEmailConfirmationUserMixin, AbstractUser):
    name = models.CharField(max_length = 50)
    username = models.CharField(max_length = 50, null=True)
    email = models.EmailField(unique=True, null=True)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['name','username']
    

I tried to make everything but it didn’t work. I don’t receive any error but also I don’t send any email

Please be more specific. What exactly is happening?

Are you seeing your createuser form?

Are you handling the POST correctly? (Is it doing what you’re expecting it to do?)

Are you redirecting to the confirm-email view?

Is it showing you the expected form?

Are you able to send emails from any part of your project?

Have you confirmed that your email settings are correct? (Have you tested them?)