principle:
First: Apply for a large number of mailbox accounts Tencent's 126 of the 163 Sina yahoo Google and so on to provide the SMTP Service
Second: Collect the mailing list you want to send the mail
Third: Traverse mailing list, each message Send a message
Fourth: Run with Linux under timed script background I ran for two days haha, because in order to ensure as much as possible to send every success
principle is very simple, but there are still many problems encountered.
First: The problem of the failure of the message, I use two ways to solve, the first large number of those mailboxes to send the number, until successful. Then randomly split the send-mailbox list (to avoid a persistent failure) after sending 500 emails each time.
I'm using Phpmailer
a lot of the code is not much said. Phpmailer everyone to search their own downloads
Portal script: is the Linux implementation of the mail_001.php
<?php define (' Root_path ', DirName (__file__)); Require_once ' library/senderapi.php '; Send mail interface require_once ' config/senderlistconf.php ';
Send email account list/Read text email address shuffle ($senderListConf);
$filename = "Data/email.txt";
$fp = fopen ($filename, "R");
$contents = Fread ($fp, FileSize ($filename));
$list _email=explode ("\ r \ n", $contents);
$len =count ($list _email);
Fclose ($FP);
The content of the message is the content on the Web page $htmlContent = file_get_contents (' http://taobao.1080www.com ');
Parameter description (Sent to, mail subject, message content, additional information, username) foreach ($list _email as $key => $value) {$value = Trim ($value);
$rs =explode ("@", $value);
$user _name = $rs [' 0 ']; Smtp_mail ($value, ' Autumn Moisturizing cosmetics _ Autumn Skin Care Skin Care _ Autumn dry How to do-little common sense ', $htmlContent, ' http://taobao.1080www.com/', $user _name,$
senderlistconf,0);
Sleep (3); if ($key%200 = = 0 && $key >0) {shuffle ($senderListConf);///Every 200 times, send the message in an order to disrupt it once} die (' Sendingover ... ...........'."
\ r \ n "); ?
Encapsulation Phpmailer senderapi.php
<?php//Request Phpmailer class file error_reporting (E_error);
Require_once ("phpmailer/phpmailer.class.php");
Write send result function info_write ($filename, $info _log) {$info. = $info _log;
$info. = "\ r \ n";
$fp = fopen ($filename, ' a ');
Fwrite ($fp, $info);
Fclose ($FP);
//Email functions function smtp_mail ($sendto _email, $subject, $body, $extra _hdrs, $user _name, $senderListConf, $sender =0) {
$batch _no = Date ("Y_m_d_h");
$mail = new Phpmailer ();
$mail->issmtp ();
$sender _info = $senderListConf [$sender]; if (! $sender _info) ' Die send an account error ... ';... Send via SMTP $mail->host = $sender _info[' Host ']; SMTP servers $mail->smtpauth = true; Turn on SMTP authentication $mail->username = $sender _info[' Username ']; SMTP username Note: Ordinary mail authentication does not need to add @ domain name $mail->password = $sender _info[' Password ']; SMTP password $mail->from = $sender _info[' Username ']; Sender mailbox $mail->fromname = "Taobao recommended---TaoBao"; Senders, such as the China Fund Management Network $maIl->charset = "UTF-8";
This specifies the character set!
$mail->encoding = "base64"; $mail->addaddress ($sendto _email, $user _name);
Recipient mailbox and name $mail->addreplyto ("ken@cscsws.com", "Taobao recommended"); $mail->wordwrap = 50; Set word wrap//$mail->addattachment ("/var/tmp/file.tar.gz"); Attachment Annex 1//$mail->addattachment ("/home/www/images/zhuanti/qiujibushui/qiujibushui_attache.jpg", " New.jpg "); Annex 2 $mail->ishtml (TRUE);
Send As HTML $mail->subject = $subject;
The content of the message can be sent directly to the HTML file $mail->body = $body;
$mail->altbody = "text/html"; if ($mail->send ()) {info_write (Root_path. ') /log/'. $batch _no. "
Ok.txt "," $user _name sent successfully "); else {info_write (root_path. ') /log/'. $batch _no. "
Falied.txt "," $user _name failed, send account ". $sender _info[' Username '].", error message $mail->errorinfo "); if ($senderListConf [$sender +1]) {$sender = Smtp_mail ($sendto _email, $subject, $body, $extra _hdrs, $user _name, $sen Derlistconf, ($sender+1));
} return $sender; }
Send a message column representation example senderlistconf.php
<?php $senderListConf = Array (//Sohu Mailbox Array (' Host ' => ' smtp.sohu.com ', ' Username ' => ' youemail@sohu.com ', ' Pa ssWOrd ' => ' YourPassword '),//Yahoo email array (' Host ' => ' smtp.mail.yahoo.com ', ' Username ' => ' youemail@yahoo.cn ', ' " Password ' => ' YourPassword '),//163 mailbox Array (' Host ' => ' smtp.163.com ', ' Username ' => ' youemail@163.com '), ' Password ' => ' YourPassword '),//126 mailbox Array (' Host ' => ' smtp.126.com ', ' Username ' => ' youemail@126.com '), ' Password ' => ' YourPassword '),//qq mailbox Array (' Host ' => ' smtp.qq.com ', ' Username ' => ' youemail@qq.com ', ' Password ') => ' YourPassword '),//Google email Array (' Host ' => ' smtp.gmail.com ', ' Username ' => ' youemail@gmail.com ', ' Password ' = > ' YourPassword '),//139 mailbox Array (' Host ' => ' smtp.139.com ', ' Username ' => ' youemail@139.com ', ' Password ' => ') YourPassword '),//qq mailbox Array (' Host ' => ' smtp.qq.com ', ' Username ' => ' youemail@qq.com ', ' Password ' => ') ( YourPassword '),);