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:
- Digital signatures that support message S/MIME encryption
- Support mail multiple TOs, CCs, BCCs and Reply-tos
- Can work on any server platform, so don't worry about the win platform can't send mail the problem
- Supports text/html format messages
- Image images can be embedded
- Support for HTML reading is not supported for mail clients
- Powerful debug function for sending mail
- Custom Mail Header
- Redundant SMTP server support
- Supports 8bit, base64, binary, and quoted-printable codes
- Word Wrap
- Support multi-attachment sending function
- Support for SMTP server Authentication feature
- Tested successfully on SendMail, QMail, Postfix, Gmail, Imail, and Exchange platforms
- The download file provided includes a detailed description of the documentation and sample instructions, so don't worry about the difficulty of getting started!
- 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