[英]Sending Verification Email from Java Program - AuthenticationError
[英]Sending a verification code Link in email
我是编程新手。 我将如何在电子邮件中发送验证链接?
我设法发送了电子邮件,但没有发送验证码,用户必须点击该验证码才能完成注册。 提前致谢。
这是发送邮件的代码。
public static void send() {
String to = "rchiluano@partnersolutions.com.ph";//change accordingly
String from = "hryanmark@gmail.com";//change accordingly
String host = "localhost";//or IP address
//Get the session object
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
//compose the message
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Verify your Account");
message.setText("\tWe receive your request for registration. \n \n
\tPlease click the Link below to complete the registration\n" +
"");
// Send message
Transport.send(message);
System.out.println("Sent");
}catch (MessagingException mex) {mex.printStackTrace();}
}
您需要在链接上添加一个带有唯一标识符的参数(随机数+当前日期...或者我不知道您的选择)。此外,您还需要将该随机数存储在与您的用户相对应的数据库中表格。当页面打开时,您只需更新数据库中的一栏,即可跟踪用户是否已激活对应于该链接的唯一标识符的帐户。 此处添加参数的示例如何将url参数添加到当前url? ;
您需要在您的链接中添加一个带有唯一标识符的参数(随机+当前日期......或者我不知道您的选择)。此外,您需要将该随机数存储在您的用户中与您的用户相对应的数据库中桌子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.