0

我在我的本地机器上尝试了下面的代码,它工作正常,但是当我在雅虎小型企业上托管它时,它一直给出“SMTP connect() failed”。我能做些什么?

 $mail             = new PHPMailer();
              $body             = $message;
              $mail->IsSMTP();
              $mail->SMTPAuth   = true;
              $mail->Host       = "smtp.bizmail.yahoo.com"; //Outgoing mail (SMTP) server
              $mail->Port       = 465;
              $mail->Username   = "myadminmail@mydomain.net";
              $mail->Password   = "mypassword";
              $mail->SMTPSecure = 'tls';
              $mail->SetFrom('myadminmail@mydomain.net', 'name',false);
              $mail->Subject    = $subject;
              $mail->AltBody    = "Any message.";
              $mail->MsgHTML($body);

              $address = $to;
              $mail->AddAddress($address, $name);
              if(!$mail->Send()) {
                  echo 'Mailer Error: ' . $mail->ErrorInfo;
              } else {
                    echo 'Mailer Sent: ' ;
             }
4

3 回答 3

0

换行:

 $mail->IsSMTP();

为了:

 $mail->isMail(true);
于 2015-08-06T20:35:03.550 回答
0

好的,谢谢大家,我通过删除这一行 $mail->IsSMTP(); 让它工作了

于 2015-08-04T11:13:26.733 回答
0

这对我有用:

$mail->SMTPDebug = 1;
$mail->isMail(true);
$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Host = "smtp.bizmail.yahoo.com"; // SMTP server

然后,您必须登录到您的 Yahoo 帐户,然后点击此链接:

https://login.yahoo.com/account/security#other-apps

激活“允许安全性较低的应用程序”。

于 2017-06-15T00:29:45.713 回答