Zunitasingh

Untitled

May 10th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. <?php
  2. require("../lib/PHPMailerAutoload.php"); // path to the PHPMailerAutoload.php file.
  3.  
  4. ini_set("memory_limit","1520M");
  5. $headers = "From:".$ip_pair."\r\n";
  6. $headers.='MIME-Version:1.0' . "\r\n";
  7. $headers.='Content-type:text/html; charset=iso-8859-1' . "\r\n";
  8. $sub = $_REQUEST['sub'];
  9. $ofrom = $_REQUEST['from'];
  10. $msg = $_REQUEST['message'];
  11. $limit = $_REQUEST['limit'];
  12. $emails = $_REQUEST['emails'];
  13. $offer = $_REQUEST['offer'];
  14. $userid = $_REQUEST['userid'];
  15. $domain = $_REQUEST['domain'];
  16. $type = $_REQUEST['type'];
  17. $data = $_REQUEST['data'];
  18. $mode = $_REQUEST['mode'];
  19. $head= $_REQUEST['head'];
  20. $ip_pair=trim($_REQUEST['ip']);
  21. $d = @date("YmdHis");
  22. $url = '$offer#$id';
  23. $url = base64_encode($url);
  24. $mid = time().'-'.md5($ip_pair.$emails).'@mail.smtp.com';
  25. #$url=urlencode($url);
  26. $message_text=str_replace("{domain}",$domain,$msg);
  27. $message_text=str_replace("{url}",$url,$message_text);
  28. $message_text=str_replace("{email}",$email,$message_text);
  29. $message_text=str_replace("{name}",$name,$message_text);
  30. $message_text=str_replace("{id}",$id,$message_text);
  31. $subject="$sub";
  32. $from="\"$ofrom\" <$ip_pair>";
  33.  
  34. $mail = new PHPMailer();
  35. //$mail->SMTPDebug = 2; // For detailed information messages
  36. $mail->IsSMTP();
  37. $mail->Mailer = "smtp";
  38. $mail->Host = "smtp.gmail.com"; //Enter your SMTP account's SMTP server.
  39.  
  40. $mail->Port = "465"; // 25, 2525, 25025, 2082 can also be used. Use Port 465 for SSL.
  41.  
  42. $mail->SMTPAuth = true;
  43. //$mail->SMTPSecure = 'TLS'; // Uncomment this line if you want to use SSL.
  44.  
  45. $mail->Username = "xxxxxx@gmail.com";
  46. $mail->Password = "yyyyyyy";
  47.  
  48. $mail->From = $ip_pair;
  49. $mail->FromName = $ofrom;
  50. //$mail->AddAddress("xyxyxyxyxy@gmail.com");
  51. $mail->AddReplyTo($ip_pair, $ofrom);
  52.  
  53. $mail->Subject = $subject;
  54. $mail->Body = $message_text;
  55. $mail->IsHTML(true);
  56. $mail->WordWrap = 50;
  57.  
  58. if($mode=='test')
  59. {
  60. $lines=explode("\n",$emails);
  61. $st = date("Y-m-d G:i:s");
  62. foreach ($lines as $emaila)
  63. {
  64. $mail->ClearAddresses();
  65. $mail->AddAddress($emaila, "");
  66.  
  67. if(!$mail->Send()) {
  68. echo 'Message was not sent.';
  69. echo 'Mailer error: ' . $mail->ErrorInfo;
  70. exit;
  71. } else {
  72. //echo 'Message has been sent.';
  73. }
  74. }
  75. echo '....done.';
  76. }
  77. elseif($mode == "bulk") // Bulk mailing
  78. {
  79. $count=0;
  80. $datafile="/var/www/html/wp-mail/data/$data";
  81. $fp = fopen($datafile,"r");
  82. $st = date("Y-m-d G:i:s");
  83. while(!feof($fp))
  84. {
  85. $buffer = fgets($fp, 4096);
  86. @list($emaila,$id,$isp)=explode("|",$buffer);
  87. if($limit > 1)
  88. {
  89. $mail->ClearAddresses();
  90. $mail->AddAddress($emaila, "");
  91.  
  92. if(!$mail->Send()) {
  93. echo 'Message was not sent.';
  94. echo 'Mailer error: ' . $mail->ErrorInfo;
  95. exit;
  96. } else {
  97. //echo 'Message has been sent.';
  98. }
  99. }
  100. $count++;
  101.  
  102. if($count%$limit==0)
  103. {
  104. if($limit > 1)
  105. {
  106. del_lines($data,$limit);
  107. $ct=$ct+$count;
  108. }
  109. $lines=explode("\n",$emails);
  110. $mail->ClearAddresses();
  111. $mail->AddAddress($lines[0], "");
  112. if(!$mail->Send()) {
  113. echo 'Message was not sent.';
  114. echo 'Mailer error: ' . $mail->ErrorInfo;
  115. exit;
  116. } else {
  117. //echo 'Message has been sent.';
  118. }
  119. break;
  120. }
  121. }
  122. echo "done";
  123. }
  124.  
  125. function del_lines($files,$X)
  126. {
  127. # @chmod($files,0777);
  128. $files="/var/www/html/wp-mail/data/$files";
  129. $start=count(file($files));
  130. $lines = file($files);
  131. $first_line = $lines[0];
  132. $lines = array_slice($lines, $X);
  133. // Write to file
  134. $file = fopen($files, 'w');
  135. fwrite($file, implode('', $lines));
  136. fclose($file);
  137. $end=count(file($files));
  138. $diff=$start-$end;
  139.  
  140. echo "<br><br> No of ids in the file Before: <B>$start</B> After: <B>$end</B> Difference is <b>$diff</b><br>";
  141. if($diff==0){echo "<blink> <b> Change the Mode of the File or Data file is finished </b></blink>"; }
  142. }
  143.  
  144. ?>
Add Comment
Please, Sign In to add comment