def sendEmailAfterChangePassword(user): html = f''' <p>Hello <b>{user.name}</b> Your Password has been reset Successfully.</p> <p>Please login again</p> <a href="http://localhost:8000/login">login</a> ''' sendEmail(name=user.name, email=user.email, subject='Password Reset', htmlContent=html)
def post(self, request): email = request.POST.get('email') try: user = User.object.get(email=email) print(user) otp = math.floor(random.random() * 10000000) html = f''' <h4> Your Password reset Verification Code is {otp}</h4> ''' sendEmail("user", email, "Password Reset Verification Code", html) request.session['reset-password-verification-code'] = otp request.session['reset-password-email'] = email return HttpResponse("email sent") except: return redirect('/reset-password')
def post(self, request): name = request.POST.get('name') email = request.POST.get('email') otp = math.floor(random.random() * 1000000) print(name, email) html = f''' <h4>Hello {name},</h4> <br> <p>Your Verification Code is <b>{otp}</b> </p> <br> <p>If you did not request for otp then you can ignore this email.<p> Our website is <a href="www.ajul.com">www.ajul.com</a> ''' # email sending if name and email: response = sendEmail( name=name, email=email, subject="Verification Code for create account", htmlContent=html) try: if response.status_code: request.session['verification-code'] = otp return HttpResponse("{'message':'success'}", status=200) else: return HttpResponse(status=400) except: return HttpResponse(status=400)
def sendOtp(request): name = request.POST.get('name') email = request.POST.get('email') otp = math.floor(random.random() * 1000000) html = f''' <p>Hello <b>{name} </b></p> <p>Your Verification code is <b>{otp}</b></p> <p>If you don't requested to this email .you can ignore this email.</p> ''' if name and email: response = sendEmail(email=email, htmlcontent=html, name=name, subject='Verify Email') # email sending try: if response: request.session['verification-code'] = otp return HttpResponse("{'message':'success'}", status=200) else: return HttpResponse(status=400) except: return HttpResponse(status=400)
def post(self, request): print(request.POST.get('email')) email = request.POST.get('email') user = User.objects.get(email=email) try: otp = math.floor(random.random() * 1000000) html = f''' <h4>Your Password verification code is {otp}</h4> ''' sendEmail("User", email, "Password reset verification code", html) request.session['reset-password-verification-code'] = otp request.session['reset-password-email'] = email messages.success( request, "verification code is sent successfully check your email") return render(request, "reset_password.html", {"step2": True}) except: messages.error(request, "email not registered") return redirect("/reset-password")
def post(self, request): email = request.POST.get('email') user = User.objects.filter(email=email) if user: otp = math.floor(random.random() * 1000000) html = f''' <p> Your Password Reset Verification Code is <b>{otp}</b> .</p> ''' sendEmail(name='Dear User', email=email, subject='Reset Password Verification Code', htmlContent=html) request.session['reset-password-verification-code'] = otp request.session['reset-password-email'] = email else: return render(request, 'reset_password.html', { 'step1': True, 'error': 'Email not registered' }) return render(request, 'reset_password.html', {'step2': True})
def sendOtp(request): name = request.POST.get('name') email = request.POST.get('email') otp = math.floor(random.random() * 10000000) html = f''' <h4>hello {name} </h4> <br> <p>your Verification Code is</p> <b>{otp}</b> <br> <p>if you didnt requested verfication code , you can ignore this email</p> ''' print(name, email) if name and email: response = sendEmail(name=name, email=email, htmlContent=html, subject='verify Email') try: if (response.status_code == 200): request.session['verification-code'] = otp return HttpResponse("{'message':'success'}", status=200) else: return HttpResponse(status=400) except: return HttpResponse(status=400)
def sendOtp(request): name = request.POST.get('name') email = request.POST.get('email') otp = math.floor(random.random() * 100000) html = f''' <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;"> <!-- HIDDEN PREHEADER TEXT --> <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"> We're thrilled to have you here! Get ready to dive into your new account. </div> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <!-- LOGO --> <tr> <td bgcolor="#FFA73B" align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#FFA73B" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;"> <h1 style="font-size: 48px; font-weight: 400; margin: 2;">Welcome!</h1> <img src="https://cdn.pixabay.com/photo/2016/04/06/13/35/hand-1311786__340.png" width="125" height="120" style="display: block; border: 0px;" /> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">We're excited to have you get started. First, you need to confirm your account. Just Copy paste the code in the website.</p> </td> </tr> <tr> <td bgcolor="#ffffff" align="left"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" style="border-radius: 3px;" bgcolor="#FFA73B"><p style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; color: #ffffff; text-decoration: none; padding: 15px 20px; border-radius: 2px; border: 1px solid #FFA73B; display: inline-block;">{otp}</p></td> </tr> </table> </td> </tr> </table> </td> </tr> <!-- COPY --> <tr> <td bgcolor="#ffffff" align="left" style="padding: 0px 30px 0px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">Just copy and paste the following code in your signUp Form and Verify :</p> </td> </tr> <!-- COPY --> <tr> <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 20px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;"><a href="#" target="_blank" style="color: #FFA73B;">If you didn't requested verification code ,You can ignore this email</a></p> </td> </tr> <tr> <td bgcolor="#ffffff" align="left" style="padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">Cheers,<br>Digital-Shop Team</p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#FFECD1" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2> <p style="margin: 0;"><a href="#" target="_blank" style="color: #FFA73B;">We’re here to help you out</a></p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#f4f4f4" align="left" style="padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;"> <br> <p style="margin: 0;">If these emails get annoying, please feel free to <a href="#" target="_blank" style="color: #111111; font-weight: 700;">unsubscribe</a>.</p> </td> </tr> </table> </td> </tr> </table> </body> ''' print(name, email) if name and email: response = sendEmail(name=name, email=email, htmlContent=html, subject="Verify your Email") try: if (response.json()['messageId']): request.session['verification-code'] = otp return HttpResponse("{'message : 'success' }", status=200) else: return HttpResponse(status=404) except: return HttpResponse(status=404)
def sendEmailAfterChangePassword(user): html = "<h2>Password Changed Successfully.......<h2>" sendEmail(user.name, user.email, "Password Changed", html)
def sendEmailAfterChangePassword(user): html = ''' <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;"> <!-- HIDDEN PREHEADER TEXT --> <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"> Your password Reset done finally we can login with new password . </div> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <!-- LOGO --> <tr> <td bgcolor="#FFA73B" align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#FFA73B" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;"> <h1 style="font-size: 48px; font-weight: 400; margin: 2;">Reset Success !!<br> </h1> <img src="https://image.freepik.com/free-vector/completed-concept-illustration_114360-3891.jpg" width="150" height="140" style="display: block; border: 0px;" /> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="left"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <b >PassWord change done successfully <b> ..<br> Now ,You can login with new passWord <a href="/login">here ... </a></p> </tr> </table> </td> </tr> </table> </td> </tr> <!-- COPY --> <tr> <td bgcolor="#ffffff" align="left" style="padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">Cheers,<br>Digital-Shop Team</p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#FFECD1" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2> <p style="margin: 0;"><a href="#" target="_blank" style="color: #FFA73B;">We’re here to help you out</a></p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#f4f4f4" align="left" style="padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;"> <br> <p style="margin: 0;">If these emails get annoying, please feel free to <a href="#" target="_blank" style="color: #111111; font-weight: 700;">unsubscribe</a>.</p> </td> </tr> </table> </td> </tr> </table> </body> <h1>PassWord change done successfully ..</h1> ''' sendEmail(user.name, user.email, "Password Changed ", htmlContent=html)
def post(self, request): #print(request.POST.get('email')) email = request.POST.get('email') print(email) try: user = User.objects.get(email=email) print(user) otp = math.floor(random.random() * 100000) print(otp) html = f''' <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;"> <!-- HIDDEN PREHEADER TEXT --> <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"> Your password reset verification code is here . </div> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <!-- LOGO --> <tr> <td bgcolor="#FFA73B" align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td align="center" valign="top" style="padding: 40px 10px 40px 10px;"> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#FFA73B" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;"> <h1 style="font-size: 48px; font-weight: 400; margin: 2;">Password Reset Code!!</h1> <img src="https://image.freepik.com/free-vector/illustration-cloud-security-icon_53876-6325.jpg" width="200" height="200" style="display: block; border: 0px;" /> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">Your password reset Verification code is here.Just copy paste code this code on the code verification box to verify the account .</p> </td> </tr> <tr> <td bgcolor="#ffffff" align="left"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" style="border-radius: 3px;" bgcolor="#FFA73B"><p style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; color: #ffffff; text-decoration: none; padding: 15px 20px; border-radius: 2px; border: 1px solid #FFA73B; display: inline-block;">{otp}</p></td> </tr> </table> </td> </tr> </table> </td> </tr> <!-- COPY --> <tr> <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 20px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;"><a href="#" target="_blank" style="color: #FFA73B;">If you didn't requested verification code ,You can ignore this email</a></p> </td> </tr> <tr> <td bgcolor="#ffffff" align="left" style="padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <p style="margin: 0;">Cheers,<br>Digital-Shop Team</p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 30px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#FFECD1" align="center" style="padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;"> <h2 style="font-size: 20px; font-weight: 400; color: #111111; margin: 0;">Need more help?</h2> <p style="margin: 0;"><a href="#" target="_blank" style="color: #FFA73B;">We’re here to help you out</a></p> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;"> <tr> <td bgcolor="#f4f4f4" align="left" style="padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;"> <br> <p style="margin: 0;">If these emails get annoying, please feel free to <a href="#" target="_blank" style="color: #111111; font-weight: 700;">unsubscribe</a>.</p> </td> </tr> </table> </td> </tr> </table> </body> <h4> Your password reset Verification code is {otp} .</h4> ''' sendEmail("User", email, "Password reset verification", html) request.session['reset-password-verification-code'] = otp request.session['reset-password-email'] = email # return HttpResponse("Email sent") return render(request, 'reset-password.html', {'step2': True}) except: return redirect('reset-password')