-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailVerification.aspx.cs
More file actions
53 lines (50 loc) · 1.53 KB
/
EmailVerification.aspx.cs
File metadata and controls
53 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
namespace teachingPlatform
{
public partial class EmailVerification : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Site2 master = (Site2)this.Master;
master.SignUp.Visible = false;
master.SignIn.Visible = false;
if (!IsPostBack)
{ Random rnd = new Random();
int otp = rnd.Next(300000, 700000);
Session["OTP"] = otp;
MailMessage mm = new MailMessage("teamLearn12@gmail.com", Session["Email"].ToString().Trim());
mm.Subject = "Email Verification";
mm.Body = string.Format("Hi {0},<br /><br />OTP: {1}<br />Thank You,<br />Team Learn", Session["Name"].ToString(), otp.ToString());
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential networkcred = new NetworkCredential();
networkcred.UserName = "teamLearn12@gmail.com";
networkcred.Password = "Alohomora!";
smtp.UseDefaultCredentials = false;
smtp.Credentials = networkcred;
smtp.Port = 587;
smtp.Send(mm);
}
}
protected void SubmitClick(object sender, EventArgs e)
{
if(TextBox1.Text == Session["OTP"].ToString())
{
Response.Redirect("signIn.aspx");
}
else
{
Label2.Text = "Please check your email";
}
}
}
}