Phpmailer Message Class Usage Error analysis

Source: Internet
Author: User

The Phpmailer configuration checklist is as follows:

  1. Require_once 'class.phpmailer.php';
  2. $receiver = ";
  3. $mail = new Phpmailer ();
  4. $mail-issmtp ();
  5. $mail-ishtml (true);
  6. $mail-CharSet = "Gb2312″;
  7. $mail-Encoding = "Base64″;
  8. $mail,Host = ' mail.test.com ';
  9. $mail,Port = 25;
  10. $mail-Smtpauth = true;
  11. $mail-Username = ' Test ';
  12. $mail-Password = ' Test ';
  13. $mail from = ' [email protected] ';
  14. $mail-FromName = ' [email protected] ';
  15. $mail-addaddress ($sendto _email, $receiver);
  16. $mail-Subject = ' phpmailer mail test ';
  17. $mailBody = ' phpmailer mail test ';
  18. if (! $mail,Send ()) {
  19. Echo $mail-errorinfo; exit ();
  20. }
  21. echo ' success ';

Phpmailer Message Class Usage Error analysis

One, does not define send mailbox $mail->from or malformed, error prompt: Language string failed to load:recipients_failed [email protected], note , this configuration must be correct, and is the correct mailbox

Two, there is no mail service host defined $mail->host or Connection failed, error message: Language string failed to Load:connect_host

Three, there is no definition to send the mailbox $mail->addaddress or the mailbox format is incorrect, error message: Language string failed to load:provide_address

Four, does not define the mailbox send user name $mail->username, error message: Language string failed to Load:connect_host

Five, no defined mailbox send password $mail->password, error message: Language string failed to load:connect_host, such errors are very obvious, The mailbox server is generally configured incorrectly and cannot be connected.

Six, message body encoding, if you send an HTML message, you need to define the correct encoding format and character, send GBK message as follows:
$mail->ishtml (TRUE); Whether HTML mail is supported
$mail->charset = "Gb2312″; Character settings
$mail->encoding = "Base64″; Encoding method
After configuration, you can send HTML messages directly, as follows:

    1. <meta http-equiv= "Content-type" content= "text/html; CharSet=gb2312"/>
    2. <title>phpmailer Mail Test </title>
    3. <body>
    4. <div>phpmailer Message Class Usage Error analysis </div>
    5. </body>

Seven, learn to use the error prompt correctly $mail->errorinfo View the message error, you can directly find the problem.

Using the Phpmailer message class to send messages using a very simple, basic configuration as shown above, in the use of the correct understanding of error prompts, and timely understanding of the cause of the error, for the correct use of Phpmailer message class is very important.

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.