PHP Send mail class library Phpmailer simple use _php tutorial

Source: Internet
Author: User
Tags php send mail word wrap
Recently, the ability to send mail was sent using the mail () function from PHP. PHP mail () This method is very simple, convenient, easy to use, but in addition to NetEase mailbox, QQ mailbox, Gmail mailbox and other commonly used mailboxes can be received, after testing Hotmail, TOM, live and other mailboxes are not receiving such mail. So instead of using Phpmailer, this powerful mail-sending class.

Some examples of the use of the official band, some will be reported Mailer error:could not instantiate mail function. This error. After referencing some information, I wrote a method. The code is simple enough to explain.

function mailto ($nickname, $address, $id, $activation _code) {date_default_timezone_set (' PRC '); Include_once (" Class.phpmailer.php "); $mail = new Phpmailer (); Defaults to using php "Mail ()" $mail->issmtp (), $mail->host = "smtp.163.com";//SMTP server $mail->smtpauth = True            ; Open SMTP authentication $mail->username = "bkjia@163.com";          User name $mail->password = "YourPassword"; Password//$body = file_get_contents (' application/views/nmra/register.html ');//$body = preg_replace ('/\\\\/', ', $body); Strip backslashes$body = '

'; $body. = '; $body. = '; $body. = '

'. $nickname. ', hello.

'; $body. = '

Congratulations on becoming the "$id." Member of the Research Association of the Help House.

'; $body. = '

The community of Bangke Researchers Association is a Community of program apes, siege lions, design lions and developers for technical exchanges and topic discussions. Hopefully here you can find topics of interest with like-minded friends.

'; $body. = ' Please click on the link below to verify your email address, please note that the domain name is bkjia.com:http://www.bkjia.com/librarys/accounts/activation/?code= '. $activation _ Code. "; $body. = '

I wish you a pleasant work and a comfortable life.

'; $body. = '';//echo $body; $mail->addreplyto ("bkjia@163.com", "Gonn"), $mail->setfrom (' bkjia@163.com ', ' gonn '); $mail- >addreplyto ("bkjia@163.com", "gonn"); $address = "252211974@qq.com";//$address = "bkjia@gmail.com"; $mail AddAddress ($address, $nickname); $subject = "Mail received from a customer's home"; $mail->subject = "=? UTF-8? B? ". Base64_encode ($subject). "? = ";//optional, comment out and test$mail->altbody =" To view the message, please use an HTML compatible email viewer! " ; $mail->msghtml ($body);//$mail->addattachment ("Images/phpmailer.gif"); attachment//$mail->addattachment ("Images/phpmailer_mini.gif"); Attachmentif (! $mail->send ()) {//echo "Mailer Error:". $mail->errorinfo;} else {//echo "Message sent!";}}

As long as the use of the introduction of two PHP classes, and then write their own method is OK, two classes are small, send mail fast.

Phpmailer is a powerful message class with its main functional features:

    1. Digital signatures that support message S/MIME encryption
    2. Support mail multiple TOs, CCs, BCCs and Reply-tos
    3. Can work on any server platform, so don't worry about the win platform can't send mail the problem
    4. Supports text/html format messages
    5. Image images can be embedded
    6. Support for HTML reading is not supported for mail clients
    7. Powerful debug function for sending mail
    8. Custom Mail Header
    9. Redundant SMTP server support
    10. Supports 8bit, base64, binary, and quoted-printable codes
    11. Word Wrap
    12. Support multi-attachment sending function
    13. Support for SMTP server Authentication feature
    14. Tested successfully on SendMail, QMail, Postfix, Gmail, Imail, and Exchange platforms
    15. The download file provided includes a detailed description of the documentation and sample instructions, so don't worry about the difficulty of getting started!
    16. Phpmailer is very small, simple, convenient and fast

http://www.bkjia.com/PHPjc/752342.html www.bkjia.com true http://www.bkjia.com/PHPjc/752342.html techarticle recently, the ability to send mail was sent using the mail () function from PHP. PHP mail () This method is very simple, convenient, easy to use, but in addition to NetEase mailbox, QQ mailbox 、...

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