Phpmailer cannot connect to the server due to issues related to sending emails

Source: Internet
Author: User
Phpmailer is sending emails. if phpmailer is not used to send emails when the server is connected, two errors are reported... 1. use gmail, sohu, 126 ..... I can't connect to the server, but later I used my QQ mailbox to connect to the server. I can also send emails, but it is unstable. sometimes it will fail to be sent... then it is estimated that it is a problem with the service provider. phpmailer cannot connect to the server due to an email sending problem
Two errors occurred when sending emails with phpmailer...

1.
When using phpmailer documentation to bring your own code, you can use gmail, sohu, 126... to connect to the server.

But later I used my QQ mailbox to connect to and send emails, but it was unstable. sometimes it would fail to be sent... then I guess it was a problem with the service provider ....

2. emails sent via QQ mail are easy to use locally for 100%, so it is difficult to upload emails to the server.

The Error message is SMTP Error: cocould not connect to SMTP host.

I thought it was a php. ini problem. I just looked at it...

Sendmail_from no value
Sendmail_path no value
SMTP localhost
Smtp_port 25 25

The configuration of the server is the same as that of the local server, so it is not easy to use.

The following code has been tested locally and can be sent. the server does not work.
PHP code
  // Phpmailer class require_once (". /plugin/phpmailer/class. phpmailer. php "); require_once (". /plugin/phpmailer/class. smtp. php "); // write your own functionfunction SendMailToClient ($ client) {$ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> SMTPAuth = true; // Set to security authentication mode $ mail-> Host = "smtp.qq.com"; // SMTP server address $ mail-> Username = "xxxxxx@qq.com "; // login username $ mail-> Password = "psw"; // login Password $ mail-> From = "xxxxxx@qq.com"; // sender Person address (username@163.com) $ mail-> FromName = "sender name"; $ mail-> WordWrap = 50; $ mail-> IsHTML (true); // whether html mail is supported, true or false $ mail-> AddAddress ("$ client"); // customer email address $ mail-> Subject = "title "; $ mail-> Body = "text content"; if (! $ Mail-> Send () {echo "Message cocould not be sent.

"; Echo" Mailer Error: ". $ mail-> ErrorInfo; return FALSE;} return TRUE;} // call the $ client =" client@mail.com "; SendMailToClient ($ client );



------ Solution --------------------
Does the firewall not allow you to access smtp.qq.com?
------ Solution --------------------
It must be a server problem.
The server and local configuration are the same. this is a bit skeptical.
It must be caused by different settings.
------ Solution --------------------
PHPMailer remembers that there is a debug option. the landlord sets this to true to see if there is a Xiami prompt O (Taobao _ Taobao) O ~

Professional essay search engine
------ Solution --------------------
Does the smtp server use localhost? The server configuration is different from the local configuration.
You can debug it upstairs.
Top

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.