PHP mail sending class PHPMailer_PHP tutorial

Source: Internet
Author: User
In-depth discussion of PHP mail sending class PHPMailer. PHPMailer is a mail sending class specifically used in php language. it has powerful functions and enriches PHP's single mail () function. Supports SMTP and even attachments. PHPMailer compliance

PHPMailer is a mail sending class specifically used in php language. it has powerful functions and enriches PHP's single mail () function. Supports SMTP and even attachments.

PHPMailer complies with the LGPL authorization and can be downloaded free of charge. The current version is PHPMailer v2.2.1 updated on July 22, November 16, 2007.
: Http://phpmailer.codeworxtech.com/index.php? Pg = sf & p = dl
Note: When downloading a file with a suffix of .tar.gz and. zip, all files contained in the file are compressed in different formats. .tar.gz is compressed in double mode and the file size is smaller. WinRAR can decompress these two formats correctly.

◆ Usage:

☆Note: After decompression, there will be an examples folder with "pop3_before_smtp_test.php" and "test1.php" files. The first file shows the basic usage (see below), while "test1.php" provides detailed instructions. another file named contents.html is the Mail content, which can be replaced with the mail template in the future, it is used to increase mail standardization and enrichment.

☆Basic method: pop3_before_smtp_test.php

 
 
  1. <? Php
  2. Require 'class. phpmailer. php ';
  3. Require 'class. pop3.php ';
  4. $ Pop = new POP3 ();
  5. // Create an object to receive emails
  6. $ Pop-> Authorise ('pop3 .example.com'
    , 110, 30, 'mailer', 'password', 1 );
  7. // Set the email receiving user information
  8. // Pop3.example.com: the pop3 server that is rewritten to the mailbox
  9. // For example, 163 is pop3.163.com
  10. // Mailer: User name
  11. // Password: password
  12. $ Mail = new PHPMailer ();
  13. // Create an object and send an email. if you only send an email, you can remove the above
  14. // Pop3 and the inclusion of class. pop3.php
  15. $ Mail-> IsSMTP ();
  16. // Unchanged
  17. $ Mail-> SMTPDebug = 2;
  18. $ Mail-> IsHTML (true );
  19. // Whether HTML mail can be sent. the default value is false,
  20. // To facilitate the subsequent use of the "email template", we should change it to true
  21. $ Mail-> Host = 'relay .example.com ';
  22. // Email server
  23. // For example, the 163 email address is smtp.163.com.
  24. $ Mail-> From = 'mailer @ example.com ';
  25. // Your email address
  26. $ Mail-> FromName = 'example Mailer ';
  27. // Your name
  28. $ Mail-> Subject = 'My subobject ';
  29. // Mail title
  30. $ Mail-> Body = 'Hello World ';
  31. // Email content. you can use the new feature to call emails.
    Template. for details, refer to the following section.
  32. $ Mail-> AddAddress ('name @ anydomain.
    Com ', 'First last ');
  33. // Recipient's email address and name
  34. If (! $ Mail-> Send ())
  35. {
  36. Echo $ mail-> ErrorInfo;
  37. }
  38. ?>

We hope that the PHPMailer knowledge described above can be used as your reference.


Pure PHP's single mail () function. Supports SMTP and even attachments. PHPMailer complies...

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.