SMTP错误:不接受数据使用PHPMailer获取错误

时间:2016-11-09 19:28:38

标签: php email phpmailer

$mail->From = "info@example.com";
$mail->FromName = "Example";
$mail->AddAddress($regMail);
$mail->AddReplyTo("info@examples.com");
$mail->IsHTML(true);          
$mail->Subject = 'Please verify your Email Address';
$mail->Body    = 'To proceed with your account, we need to make sure this email address is yours. 
Please click the below link to verify your email. <br/>http://example.com/activate.php?encrypt='.$valKey.'&email='.$regMail.'&action=activate
<br><br>If you didn\'t make this request, just ignore this mail.';

我收到这些代码的错误。但是,当我从正文中删除链接时,邮件发送成功。我不知道为什么,请帮帮我。在此先感谢

1 个答案:

答案 0 :(得分:0)

try some thing like this for smtp

    require 'phpmailer/PHPMailerAutoload.php';

    $mail = new PHPMailer(); 
    $mail->IsSMTP(); 
    $mail->SMTPDebug = 1; 
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = 'ssl'; 
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465; 
    $mail->Username = ""; //Username removed
    $mail->Password = ""; //Password removed
    $mail->addReplyTo('info@examples.com');
    $mail->SetFrom('emailOne@example.com', 'my name');
    $mail->Subject = 'Please verify your Email Address ';
    $mail->AddAddress('example@yahoo.com', 'my name');
    $mail->Body    = 'To proceed with your account, we need to make sure this email address is yours. 
Please click the below link to verify your email. <br/>http://example.com/activate.php?encrypt='.$valKey.'&email='.$regMail.'&action=activate
<br><br>If you didn\'t make this request, just ignore this mail.';
    if($mail->Send()) {
        echo "Message sent!";
    }else {
        echo "Mailer Error: " . $mail->ErrorInfo;
    }

download phpmailer here https://github.com/PHPMailer/PHPMailer

Turn on here https://www.google.com/settings/security/lesssecureapps