In-depth discussion of PHP Mail sending class phpmailer_php tutorial

Source: Internet
Author: User

Phpmailer is a mail-sending class specifically for the PHP language, which is very powerful and enriches PHP's own single mail () function. Support SMTP and even accessories.

Phpmailer complies with LGPL authorization and can be downloaded free of charge, the current version is Phpmailer v2.2.1 updated on November 16, 2007.
Download Address: HTTP://PHPMAILER.CODEWORXTECH.COM/INDEX.PHP?PG=SF&P=DL
Note: The suffixes of the download are. tar.gz and. zip, in fact they contain the same files, but the compression format is different. tar.gz after a double compression, the file is smaller, WinRAR software can correctly extract the two formats.

How to use:

☆ Pre-note: After decompression, the package will have a examples folder, there are "pop3_before_smtp_test.php" and "test1.php" two files. The first of these files is the basic use of the professor (see below), while "test1.php" mainly introduces some new features, these are in the same folder "Index.html" to make a detailed description, the other file "contents.html" is the message content, You can later replace the message template to increase the normalization and enrichment of messages.

☆ Basic Method: pop3_before_smtp_test.php

 
 
  1. < ? PHP
  2. Require ' class.phpmailer.php ';
  3. Require ' class.pop3.php ';
  4. $ Pop = New POP3 ();
  5. Building objects, receiving mail
  6. $pop- > authorise (' pop3.example.com '
    , Mailer, ' n ', ' password ', 1);
  7. Set up user information for receiving messages
  8. Pop3.example.com: POP3 server rewritten as a mailbox
  9. For example, 163 is pop3.163.com
  10. Mailer: User Name
  11. Password: password
  12. $ Mail = New Phpmailer ();
  13. Set up an object, send an e-mail, if only e-mail can be removed above
  14. POP3 part and the inclusion of class.pop3.php
  15. $mail- > issmtp ();
  16. Not change
  17. $mail- > Smtpdebug = 2 ;
  18. $mail- > ishtml (TRUE);
  19. Whether to enable the sending of HTML mail support, the default is False,
  20. To facilitate the use of the "Mail template" later, we changed it to True
  21. $mail- > Host = ' relay.example.com ';
  22. The server that sent the mail
  23. For example, 163 mailbox is smtp.163.com
  24. $mail- > from = ' mailer@example.com ';
  25. Your e-mail
  26. $mail- > FromName = ' Example Mailer ';
  27. Your name.
  28. $mail- > Subject = ' My subject ';
  29. Message header
  30. $mail- > Body = ' Hello world ';
  31. Message content, where you can invoke the message using the new feature
    Template, see the detailed details behind.
  32. $mail- > addaddress (' Name@anydomain.
    com ', ' first Last ');
  33. Recipient's mailbox and name
  34. if (! $mail->Send ())
  35. {
  36. Echo $mail- > errorinfo;
  37. }
  38. ?>

I hope that the above-mentioned Phpmailer knowledge can be used as reference learning materials for everyone.


http://www.bkjia.com/PHPjc/446175.html www.bkjia.com true http://www.bkjia.com/PHPjc/446175.html techarticle Phpmailer is a mail-sending class specifically for the PHP language, which is very powerful and enriches PHP's own single mail () function. Support SMTP and even accessories. Phpmailer Abide by ...

  • 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.