我想使用phpmailer函数从表单发送详细信息,但我有错误:
SMTP connect()失败。消息无法发送。
邮件程序错误:SMTP connect()失败。
//start of phpmailer
<?php
mailer error:SMTP connect() failed.
require_once '_libs/PHPMailer/PHPMailerAutoload.php';
$m= new PHPMailer;
$m->isSMTP();
$m->SMTPAuth=true;
$m->SMTPSecure = "tls";
$m->SMTPDebug=2;
$m->Host ="ssl:smtp.gmail.com:465";//my mail host
$m->Username='myusername@gmail.com';
$m->Password=##########;
$m->From='email@gmail.com';
$m->AddAddress("admin@mydomain.com");
$m->AddReplyTo('myusername@gmail.com'); // Reply TO
$m->FromName="{$firstname}";
$m->Subject='paper order';
$m->WordWrap = 50;
$m->isHTML(true);
$m->Body="the details of the order are firstname {$firstname} <br> lastname {$lastname}";
if(!$m->Send())
{
echo "message could not be sent.<p>";
echo"mailer error:" .$m->ErrorInfo;
exit;
}
echo "Message has sent";
?
答案 0 :(得分:1)
官方PHPMailer Gmail example声明主持人:
$mail->Host = "smtp.gmail.com";
端口也有自己的声明:
$mail->Port = 587;
我认为这将是SMTP connect() failed
消息的原因。