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:
- 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
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 、...