1

我已经检查了我的 wamp 服务器是否使用了 openssl,并且正在检查。但是我的代码有什么问题?

$mail = new PHPMailer(true); 
$body             = 'THIS IS YOUR USERNAME:'.$row['username'].' PASSWORD: '.$row['password'].'\n PLEASE DELETE THIS MESSAGE AFTER YOU READ THIS';
$mail->SMTPDebug = 1;
$mail->IsSMTP();                // tell the class to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 587;                    // set the SMTP server port
$mail->SMTPSecure = 'tsl'; 
$mail->Host = 'smtp.gmail.com';
$mail->Username   = "dan.villarea22@gmail.com";     // SMTP server username
$mail->Password   = "password";            // SMTP server password
$mail->AddReplyTo("system@dvts.com","ADMIN");
$mail->From       = "system@dvts.com";
$mail->FromName   = "SYSTEM";
$to = "dan.villareal22@gmail.com";
$mail->AddAddress($to);
$mail->Subject  = "First PHPMailer Message";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap   = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();echo 'Message has been sent.';
4

3 回答 3

8

将 $mail->SMTPSecure = 'tsl' 更改为 $mail->SMTPSecure = 'tls'

于 2013-10-01T03:23:00.267 回答
2

尝试按如下方式更改主机选项:

$mail->Host = "ssl://smtp.googlemail.com";

于 2013-03-22T07:02:56.697 回答
0

尝试使用 $mail->Port = 465; 而不是 587 并检查以下链接中的差异。
端口 465 和 587 有什么区别?

于 2014-01-22T07:56:47.123 回答