Phpmailer examples of e-mail bulk entry

Source: Internet
Author: User
Tags word wrap
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.

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