Simple use of php send mail class library Phpmailer

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 = "[email protected]";          User name $mail->password = "YourPassword"; Password//$body = file_get_contents (' application/views/nmra/register.html ');//$body = preg_replace ('/\\\\/', ', $body); Strip backslashes$body = ' <p><body style= ' margin:10px; " ></p> '; $body. = ' <div style= ' width:640px; Font-family:arial, Helvetica, Sans-serif; font-size:14px; ">"; $body. = ' <div align= "center" ></div>"; $body. = ' <p> ' $nickname. ', hello. </p> '; $body. = ' <p> Congratulations on becoming the ' $id of the Concise Institute of Modern Magic Research. ' Members. </p> '; $body. = ' <p> Institute of Modern Magic Studies (Nowamagic Research Association)is a program of apes, siege lions, design lions and developers of technical exchanges, topic discussion of the community. Hopefully here you can find topics of interest with like-minded friends. </p> '; $body. = ' Please click on the link below to verify your email address, please note that the domain name is nowamagic.net:<a href= "http://www.nowamagic.net/librarys/accounts/ Activation/?code= "'. $activation _code. '" target= "_blank" >http://www.nowamagic.net/librarys/accounts/ Activation/?code= '. $activation _code. ' </a> '; $body. = ' <p> shun wish to work and study happily, life comfortable. </p> '; $body. = ' </div></body> ';//echo $body; $mail->addreplyto ("[email protected]", "gonn $mail->setfrom (' [email protected] ', ' gonn '); $mail->addreplyto ("[email protected]", "Gonn"); $ Address = "[email protected]";//$address = "[email protected]"; $mail->addaddress ($address, $nickname); $subject = "Receive mail from Concise modern Magic"; $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

Original link: http://www.nowamagic.net/librarys/veda/detail/1944

Simple use of php send mail class library Phpmailer

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.