Phpmailer is often used in PHP programming mail send class, for you to introduce an entry-level example, with Phpmailer for bulk mail, the need for friends, you can refer to the next. 1. Create Smtp_mail function phpmai.php
ISSMTP (); Send via smtp$mail->host = $host; SMTP Servers$mail->smtpauth = true; Turn on SMTP authentication$mail->username = $mailname; SMTP username Note: Normal mail authentication does not need to add @ domain name $mail->password = $mailpass; SMTP password$mail->from = $mailname; Sender Mailbox $mail->fromname = "Wangkan"; Sender $mail->charset = "gb2312"; Specify the character set here! $mail->encoding = "base64"; $mail->addaddress ($sendto _email, "Hello"); Recipient's mailbox and name//$mail->ADDBCC ("Mailbox", "FF"),//$mail->ADDBCC ("Mailbox", "FF"), these can be sent//$mail->addreplyto (" Test@jbxue.com "," aaa.com ");//$mail->wordwrap = 50; Set Word wrap//$mail->addattachment ("/qita/htestv2.rar"); Attachment//$mail->addattachment ("/tmp/image.jpg", "new.jpg"); $mail->ishtml (true); Send As html//message subject $mail->subject = $subject;//message content $mail->body = $text; $mail->altbody = "text/html", if (! $mail->send ()) {$error = $mail->erroRinfo;/*if ($error = = "Smtpnot")//Custom error, no connection to SMTP, the case of a swap, this situation can be re-sent {sleep (2); $song =explode ("@", $sendto _email); $ Img= ""; Smtp_mail ($sendto _email, "send". $song [0]. $biaoti, ' NULL ', ' abc ', $sendto _email, $host, $mailname, $mailpass, $img ." Send ". $song [0]. $con, ' $mail _table ');//Send mail}*/$sql =" INSERT INTO error (Error_name,error_mail,error_smtp,error_time, error_table) VALUES (' $error ', ' $sendto _email ', ' $mailname ', now (), ' $mail _table ') "; $query =mysql_query ($sql);//Send failed to save the error record}else {if ($mailname = = "Aaa@jbxue.com") {echo ""; Personal needs, can be removed} else {echo "$user _name Mail sent successfully! Please check the email confirmation! ";//Send Success}}}?> 2. Mail sending page send.php
Attached, Phpmailer Mail send class V5.1 version download address. |