私はPHPを初めて使い、PHPを使用してメールを送信します。私は、私に連絡した人の電子メールを受け入れるという私に連絡フォームを持っているので、メールは私に送られます。私はhttps://github.com/PHPMailer/PHPMailer/tree/masterからPHPMailerライブラリを使用しています。次に使用しているコードスニペットがあります。PHPMailerでSMTP connect()がエラーに失敗しました
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPSecure = 'tls';
$mail->Host = "resolver1.opendns.com"; // this SMTP server of my machine
//$mail->Host = "208.67.222.222";//ip ; which one to use the resolver1.opendns.com or 208.67.222.222 ???
$mail->From = "[email protected];//email id of the person
$mail->AddAddress("[email protected]");//my email id
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
?>
「メッセージは送信されませんでした.Mailerエラー:SMTP connect()failed」というエラーが表示されます。 私は問題が何かを得ていません..? $ mail-> Host = "";これが何を表すのかコメントしてください。
ネットワークインタフェースのIPv6アドレスがある場合、それを削除してください。 –
私はresolver1.opendns.comがあなたの電子メールを受け入れるとは思わない。 –
私は '$ mail-> Port = $ SmtpPort;'を追加する必要がありました。これは開発サーバー上で動作しましたが、それ以前のプロダクションでは動作しませんでした。 – minipif