du0923 2015-11-16 23:04
浏览 613
已采纳

无法使用PHPMailer远程连接到我的电子邮件服务器

I'm writing a PHP script using PHPMailer to send automaticaly emails. For test purposes , I've used a Gmail account with an application passsword and everything works fine. When I replace the Gmail account config with my professional email , the PHP connection script keeps loading a while and ends up with this message. the SMTPDebug is set to 3.

2015-11-16 22:43:30 SERVER -> CLIENT: +OK Dovecot ready. 2015-11-16 22:43:30 CLIENT -> SERVER: EHLO localhost

What does this mean ?

Here is the PHP function that Im using to test the connection to the email server

<?php

require('../PHPMailer-master/PHPMailerAutoload.php'); 

function smtpMailer() {
    $mail = new PHPMailer();  
    $mail->IsSMTP(); // active SMTP
    $mail->SMTPDebug = 2;  
    $mail->Host = 'mail.mycompany.com';
    $mail->Port = 587;
    //$mail->Username = "myaccount@mycompany.com";
    //$mail->Password = "mypassword";
    $mail->SetFrom = "myaccount@mycompany.com";
    $mail->FromName = 'foxy';
    $mail->addAddress('sendTo@gmail.com', 'John Doe');  
    $mail->WordWrap = 50;                                

     $mail->Subject = 'Here is the subject';
     $mail->Body = 'This is the body in plain text ';


if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}


}

smtpMailer();

?>

Error

2015-11-17 01:44:14 SERVER -> CLIENT: 220 mycompany.com ESMTP Ready 2015-11-17 01:44:14 
CLIENT -> SERVER: EHLO localhost 2015-11-17 01:44:14    
SERVER -> CLIENT: 250-mycompany.com Hello localhost 250 HELP 2015-11-17 01:44:14 
CLIENT -> SERVER: MAIL FROM: 2015-11-17 01:44:15    
SERVER -> CLIENT: 250 root@localhost... Sender ok 2015-11-17 01:44:15   
CLIENT -> SERVER: RCPT TO: 2015-11-17 01:44:16  
SERVER -> CLIENT: 503 non-authenticated user. Please check mail before sending. 2015-11-17 01:44:16 SMTP ERROR: RCPT TO command failed: 503 non-authenticated user. Please check mail before sending. 2015-11-17 01:44:16   
CLIENT -> SERVER: QUIT 2015-11-17 01:44:16  
SERVER -> CLIENT: 221 goodbye. 2015-11-17 01:44:16  SMTP Error: The following recipients failed: sendTo@gmail.com: non-authenticated user. Please check mail before sending. 
Mailer Error: SMTP Error: The following recipients failed: sendTo@gmail.com: non-authenticated user. Please check mail before sending.

Thank you .

  • 写回答

1条回答 默认 最新

  • dsdfd2322 2015-11-17 02:05
    关注

    Here is my code that working for I am using

    $mail = new PHPMailer();
    $mail->CharSet = "UTF-8";
    $mail->Username = "no-reply@mycompany.com";
    $mail->Password = "password";
    $mail->AddAddress($email);
    $mail->FromName = "Any Text";
    $mail->Subject = $sub;
    $mail->IsHTML(true);
    $mail->Body = $code;
    $mail->Host = "192.168.20.47"; // Is IP example that I show here 
    $mail->Port = 25;
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->From = $mail->Username;
    if ($mail->Send()) {
        echo "Message send!";
    }
    else {
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    

    hope it can help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。