Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("../lib/PHPMailerAutoload.php"); // path to the PHPMailerAutoload.php file.
- ini_set("memory_limit","1520M");
- $headers = "From:".$ip_pair."\r\n";
- $headers.='MIME-Version:1.0' . "\r\n";
- $headers.='Content-type:text/html; charset=iso-8859-1' . "\r\n";
- $sub = $_REQUEST['sub'];
- $ofrom = $_REQUEST['from'];
- $msg = $_REQUEST['message'];
- $limit = $_REQUEST['limit'];
- $emails = $_REQUEST['emails'];
- $offer = $_REQUEST['offer'];
- $userid = $_REQUEST['userid'];
- $domain = $_REQUEST['domain'];
- $type = $_REQUEST['type'];
- $data = $_REQUEST['data'];
- $mode = $_REQUEST['mode'];
- $head= $_REQUEST['head'];
- $ip_pair=trim($_REQUEST['ip']);
- $d = @date("YmdHis");
- $url = '$offer#$id';
- $url = base64_encode($url);
- $mid = time().'-'.md5($ip_pair.$emails).'@mail.smtp.com';
- #$url=urlencode($url);
- $message_text=str_replace("{domain}",$domain,$msg);
- $message_text=str_replace("{url}",$url,$message_text);
- $message_text=str_replace("{email}",$email,$message_text);
- $message_text=str_replace("{name}",$name,$message_text);
- $message_text=str_replace("{id}",$id,$message_text);
- $subject="$sub";
- $from="\"$ofrom\" <$ip_pair>";
- $mail = new PHPMailer();
- //$mail->SMTPDebug = 2; // For detailed information messages
- $mail->IsSMTP();
- $mail->Mailer = "smtp";
- $mail->Host = "smtp.gmail.com"; //Enter your SMTP account's SMTP server.
- $mail->Port = "465"; // 25, 2525, 25025, 2082 can also be used. Use Port 465 for SSL.
- $mail->SMTPAuth = true;
- //$mail->SMTPSecure = 'TLS'; // Uncomment this line if you want to use SSL.
- $mail->Username = "xxxxxx@gmail.com";
- $mail->Password = "yyyyyyy";
- $mail->From = $ip_pair;
- $mail->FromName = $ofrom;
- //$mail->AddAddress("xyxyxyxyxy@gmail.com");
- $mail->AddReplyTo($ip_pair, $ofrom);
- $mail->Subject = $subject;
- $mail->Body = $message_text;
- $mail->IsHTML(true);
- $mail->WordWrap = 50;
- if($mode=='test')
- {
- $lines=explode("\n",$emails);
- $st = date("Y-m-d G:i:s");
- foreach ($lines as $emaila)
- {
- $mail->ClearAddresses();
- $mail->AddAddress($emaila, "");
- if(!$mail->Send()) {
- echo 'Message was not sent.';
- echo 'Mailer error: ' . $mail->ErrorInfo;
- exit;
- } else {
- //echo 'Message has been sent.';
- }
- }
- echo '....done.';
- }
- elseif($mode == "bulk") // Bulk mailing
- {
- $count=0;
- $datafile="/var/www/html/wp-mail/data/$data";
- $fp = fopen($datafile,"r");
- $st = date("Y-m-d G:i:s");
- while(!feof($fp))
- {
- $buffer = fgets($fp, 4096);
- @list($emaila,$id,$isp)=explode("|",$buffer);
- if($limit > 1)
- {
- $mail->ClearAddresses();
- $mail->AddAddress($emaila, "");
- if(!$mail->Send()) {
- echo 'Message was not sent.';
- echo 'Mailer error: ' . $mail->ErrorInfo;
- exit;
- } else {
- //echo 'Message has been sent.';
- }
- }
- $count++;
- if($count%$limit==0)
- {
- if($limit > 1)
- {
- del_lines($data,$limit);
- $ct=$ct+$count;
- }
- $lines=explode("\n",$emails);
- $mail->ClearAddresses();
- $mail->AddAddress($lines[0], "");
- if(!$mail->Send()) {
- echo 'Message was not sent.';
- echo 'Mailer error: ' . $mail->ErrorInfo;
- exit;
- } else {
- //echo 'Message has been sent.';
- }
- break;
- }
- }
- echo "done";
- }
- function del_lines($files,$X)
- {
- # @chmod($files,0777);
- $files="/var/www/html/wp-mail/data/$files";
- $start=count(file($files));
- $lines = file($files);
- $first_line = $lines[0];
- $lines = array_slice($lines, $X);
- // Write to file
- $file = fopen($files, 'w');
- fwrite($file, implode('', $lines));
- fclose($file);
- $end=count(file($files));
- $diff=$start-$end;
- echo "<br><br> No of ids in the file Before: <B>$start</B> After: <B>$end</B> Difference is <b>$diff</b><br>";
- if($diff==0){echo "<blink> <b> Change the Mode of the File or Data file is finished </b></blink>"; }
- }
- ?>
Add Comment
Please, Sign In to add comment