doxzrb8721 2017-02-16 11:56
浏览 46

如何在Hostgator上使用PHPMailer库

I am using PHPMailer class to send emails from my contact form to my gmail account on localhost and it works fine. But when I upload it on Hostgator servers, I get errors when trying to send email. Do I use IP Address or Hostname and which port should I use? Please Assist?

PHPMailer class

require ("PHPMailer/PHPMailerAutoload.php");                      //including phpmailer class

    $mail = new PHPMailer();

    $mail->IsSMTP();                                      // set mailer to use SMTP
    $mail->SMTPDebug = 2;
    $mail->Host = "108.167.172.144  ";            //Server IP Address
    $mail->SMTPSecure = "tls";                     // Connect using a TLS connection
    $mail->Port = 587;                                //Gmail SMTP port
    $mail->SMTPAuth = true;                         // turn on SMTP authorization
    $mail->Username = "*********@gmail.com";  // SMTP username
    $mail->Password = "********";            // SMTP password

    $mail->From = "$em";                         //email of sender
    $mail->FromName = "$nm";                        //name of the sender
    $mail->AddAddress("********@gmail.com", "Patwan");        //email address of recepient and name
    $mail->AddReplyTo($em, $nm);                     //Address to which recepient will reply

    $mail->WordWrap = 100;                                   // set word wrap to 100 characters
    $mail->IsHTML(true);                                          // set email format to HTML
    $mail->Subject = "Contact  Form";    //subject of email

    $mail->Body = "Name: " . $nm . 
                  "<br>Phone: " . $phone . 
                  "<br>Email: " . $em .
                  "<br>Subject: " . $value .
                  "<br>Message: " . $msg ;

Errors

250-smtp.gmail.com at your service, [108.167.189.105] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
2017-02-16 07:38:56 CLIENT -> SERVER: STARTTLS 
2017-02-16 07:38:56 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 
2017-02-16 07:38:56 CLIENT -> SERVER: EHLO www.pwebk.com 
2017-02-16 07:38:56 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [108.167.189.105] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
2017-02-16 07:38:56 CLIENT -> SERVER: AUTH LOGIN 
2017-02-16 07:38:56 SERVER -> CLIENT: 334 VXNlcm5hbWU6 
2017-02-16 07:38:56 CLIENT -> SERVER: bW5kdW5ndTkxQGdtYWlsLmNvbQ== 
2017-02-16 07:38:56 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 
2017-02-16 07:38:56 CLIENT -> SERVER: bWFydGlubm4= 
2017-02-16 07:38:57 SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 c192sm2741709oih.39 - gsmtp 
2017-02-16 07:38:57 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 c192sm2741709oih.39 - gsmtp 
2017-02-16 07:38:57 SMTP Error: Could not authenticate. 
2017-02-16 07:38:57 CLIENT -> SERVER: QUIT 
2017-02-16 07:38:57 SERVER -> CLIENT: 221 2.0.0 closing connection c192sm2741709oih.39 - gsmtp 
2017-02-16 07:38:57 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Form could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  • 写回答

1条回答 默认 最新

  • dongying6179 2019-05-07 06:28
    关注

    Host is 'mail.domainname.com'. Port is 465. Username is one of the email accounts you created on hostgator. Password is the email account's password. SMTPsecure is 'ssl'

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b