Copy CodeThe code is as follows:
Request Phpmailer class file
Require_once ("class.phpmailer.php");
Send email function
function Smtp_mail ($sendto _email, $subject, $body, $extra _hdrs, $user _name) {
$mail = new Phpmailer ();
$mail->issmtp (); Send via SMTP
$mail->host = "smtp.163.com"; SMTP servers
$mail->smtpauth = true; Turn on SMTP authentication
$mail->username = "Jessiejl"; SMTP username Note: Normal mail authentication does not need to add @ domain name
$mail->password = "1983106"; SMTP Password
$mail->from = ""; Sender Mailbox
$mail->fromname = "WWW.NIUTW.COM"; The sender, such as the beautiful Collocation network
$mail->charset = "GB2312"; Specify the character set here!
$mail->encoding = "base64";
$mail->addaddress ($sendto _email, $user _name); Recipient's mailbox and name
$mail->addreplyto ("", "home of the Web");
$mail->wordwrap = 50; Set word Wrap
$mail->addattachment ("/var/tmp/file.tar.gz"); Attachment Accessories 1
$mail->addattachment ("/tmp/image.jpg", "new.jpg"); Annex 2
$mail->ishtml (TRUE); Send As HTML
$mail->subject = $subject;
Message content can be sent directly to HTML file
$mail->body = <<
<title>Treasurery Online Weekly</title>
EOT;
$mail->altbody = "text/html";
if ($mail->send ())
{
Info_write ("Ok.txt", "$user _name sent successfully");
}
else {
Info_write ("Falied.txt", "$user _name failure, error message $mail->errorinfo");
}
}
Send Email function end
Write send result function, error log record
function Info_write ($filename, $info _log)
{
$info. = $info _log;
$info. = "\ r \ n";
$fp = fopen ($filename, a);
Fwrite ($fp, $info);
Fclose ($FP);
}
Timed jump page function where 1000 is the time, 1 seconds, you can customize
function redirect ($url)
{
echo "";
}
Read the text email address you can also read the database
$filename = "Email.txt";
$fp = fopen ($filename, "R");
$contents = Fread ($fp, FileSize ($filename));
$list _email=explode ("\ r \ n", $contents);
$len =count ($list _email);
Fclose ($FP);
Parameter description (Sent to, message subject, message content, additional information, user name)
$i = $_get[' action '];
$i + +;
if ($i < $len)
{
$rs =explode ("@", $list _email[$i]);
$user _name = $rs [' 0 '];
echo "Sending {$i} ({$list _email[$i]}) Mail ... {$user _name} ";
Smtp_mail ($list _email[$i], ' treasurery Online weekly 12th ', $body, ' http://www.yem120.com/', $user _name);
Redirect ("action= $i");
}
else {
echo "All messages sent";
Exit
}
?>
Small thinking:
The above read article Email.txt, can also be directly QQ number, each line a number, and then use Fget () read each line QQ number, finally add QQ mailbox suffix @qq. com
http://www.bkjia.com/PHPjc/327700.html www.bkjia.com true http://www.bkjia.com/PHPjc/327700.html techarticle Copy the code as follows: PHP//Request Phpmailer class file require_once ("class.phpmailer.php");//Send email functions function smtp_mail ($sendto _emai L, $subject, $body, $extra _h ...