繁体   English   中英

phpMailer发送smtp电子邮件

[英]phpMailer send a smtp email

我正在尝试使用phpMailer发送电子邮件。

我已经下载并将文件放在“ path2”中。

php程序有3个输入:$ email,$ subject和$ body。

这是运行时的错误代码:

2014-06-24 15:48:18 SMTP ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) SMTP connect() failed. Mailer Error: SMTP connect() failed. 

这是我的代码:

<?php
    require_once("..\path2\class.phpmailer.php");
    date_default_timezone_set('America/Eastern');
    include("..\path2\class.smtp.php");
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug  = 1; 
    $mail->SMTPAuth   = True;
    $mail->SMTPSecure = "SSL";
    $mail->Host = "smtp.live.com";      
    $mail->Port = 465;                  
    $mail->Username   = "self@live.com";
    $mail->Password   = "pass1"; 
    $mail->From="self@live.com";
    $mail->Subject    = $subject;
    $mail->Body=$body;
    $mail->AddAddress($email);
    if(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent!";
    }
?>

Telnet对于测试加密连接不是很有用-openssl更好。 在您的服务器上尝试:

openssl s_client -crlf -connect smtp.live.com:465

目前,这对我来说没有来自多个国家的连接,因此也许微软终于在1998年注意到了端口465上SSL的弃用...

openssl s_client -starttls smtp -crlf -connect smtp.live.com:587

这对我来说很好,所以我建议您对代码进行以下更改:

$mail->SMTPSecure = "tls";
$mail->Port = 587;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM