donglianjiang9321 2014-06-20 17:35 采纳率: 0%
浏览 25

使用phpmailer的正确方法是什么[关闭]

i want to send details from a form using the phpmailer function but i have the error:

SMTP connect() failed. message could not be sent.

mailer error:SMTP connect() failed.

//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";


?
  • 写回答

1条回答 默认 最新

  • dongquan8753 2014-06-20 17:44
    关注

    The official PHPMailer Gmail example declares the host as such:

    $mail->Host = "smtp.gmail.com";
    

    The port gets its own declaration as well:

    $mail->Port = 587; 
    

    I would assume that would be the cause of your SMTP connect() failed message.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器