如何使用php程序界面实现PHPMAILER?我想发送验证电子邮件

时间:2017-09-13 12:14:38

标签: php email phpmailer

我刚将我的网站上传到实时服务器,它不再发送电子邮件,网络主机希望我使用PHPMAILER。问题是我的代码在过程接口中,PHPMAILER在OOP中。请帮我把OOP改为程序。



$to      = $email; // Send email to our user
$subject = 'Signup | Verification'; // Give the email a subject
$message = '

Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by copying the url below
and pasting it in your brwoser.

------------------------
Username: '.$email.'
Password: '.$pass.'
------------------------

Please copy and paste this link in the address field and press enter to activate your account:<br>
http://elam.rpaz.co.zw/verify.php?email='.$email.'&password='.$cryptpass.'

'; // Our message above including the link

$headers = 'From:noreply@rpaz.co.zw' . "\r\n";
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "mail-2.sslzol.co.zw";
$mail->Port = 6465;
$mail->Username = 'noreply@jyvukyv';
$mail->Password = 'rp15kuyuelamhvkyu';
$mail->Subject = trim("Signup | Verification");
$mail->SetFrom('noreply@rpaz.co.zw', 'RPAZ e(LAM)');
$mail->AddAddress($email);
$mail->MsgHTML($message);

try {
  $mail->send();
} catch (Exception $ex) {
  echo $msg = $ex->getMessage();
}

echo "1 record added";
mysqli_close($conn);

  header("Location: redirect.html");
     exit;
   }
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

如果你需要使用PHPMailer只是在你的PHP脚本/页面中调用它,我在这里看不到问题。喜欢

不要忘记将它包含在您的脚本中,如

include 'RouteToPHPMailer/PHPMailer';

$mail = new PHPMailer();

并且所有代码都已粘贴并且可以使用。