du42561 2017-06-06 16:56
浏览 286

SMTP connect()失败。 发送身份验证电子邮件时显示connect()失败

I'm Trying to send email via php by using php mailer, but it's showing SMTP connect() failed. here is my code. can't find out what is problem in that. if somebody help to track error it will be very helpful for me.

$mail = new PHPMailer;
$mail->isSMTP();                                   // Set mailer to use SMTP
$mail->Host = 'dds.uemtv.com';                    // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                            // Enable SMTP authentication
$mail->Username = 'no-reply@domain.pk';          // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls';                         // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                 // TCP port to connect to

$mail->setFrom('no-reply@domain.pk', 'domain');
$mail->addReplyTo($email, '$name');
$mail->addAddress($email);   // Add a recipient
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');

$mail->isHTML(true);  // Set email format to HTML

$bodyContent = '<h1>Your Registration Completed. </h1>'
$mail->Subject = 'Verify Account- Rozgar';
$mail->Body    = $bodyContent;
if(!$mail->send()) {
    echo $data->msg = $mail->ErrorInfo;
} else {
    // echo 'Message has been sent';
     echo $data->msg="Please Verify Your Email Address";
}
  • 写回答

1条回答 默认 最新

  • duanhai4046 2017-06-06 20:23
    关注

    Don't use random settings and hope it works. SMTPSecure = 'tls' will not work with Port = 465. Set Port = 587 for explicit TLS.

    In general, use the latest version, base your code on the examples provided with PHPMailer, and read the troubleshooting guide that the error messages point you to.

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作