尝试让PHPMailer使用激活电子邮件。我已经以不同的方式向身体添加了变量,电子邮件仍然是这样的 -
请点击以下激活链接:0
我不确定我在做什么,我甚至无法收到发送的电子邮件,这花了很长时间才弄明白。
$mail = new PHPMailer;
$mail->SMTPSecure = 'tls';
$mail->isSendMail();
$mail->Host = 'auth.smtp.1and1.co.uk';
$mail->Username = 'no-reply@app.com';
$mail->Password = '';
$mail->Port = 587;
$mail->CharSet = 'utf-8';
$mail->IsHTML(true);
$mail->setFrom('no-reply@app.com', (empty($user_name) ? 'app Activation: ' : $user_name));
$mail->addAddress($user_email);
$activation_link = "https://app.com/activate.php?secret=" + $email_secret;
$mail->Subject = 'app Activation: ' . $user_name;
$mail->isHTML(true);
$mail->msgHTML("Please click the activation link below: \n <a href='$activation_link'>$activation_link</a>");
$mail->AltBody = 'Please click the link! $activation_link';
if (!$mail->send()) {
$msg .= "Mailer Error: " . $mail->ErrorInfo;
$this->errors[] = "<span class='warning'>Activation email failed to send!</a></span>";
}
else {
$this->messages[] = "<span class='success'>Your account has been created successfully. You can now log in. Activation email has been sent to your email address!</a></span>";
}
电子邮件发送时不确定为什么变量值显示为随机数而不是我创建的链接。