Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. system("command clear");
  3.  
  4. //Contadores----------------------------------------------------------
  5. $GLOBALS['cont_ok'] = 1;
  6. $GLOBALS['cont_erro'] = 1;
  7. //--------------------------------------------------------------------
  8.  
  9. //$comandos = argumentos($argv);
  10.  
  11. //ConfiguraĆ§Ć£o--------------------------------------------------------
  12.  
  13. $GLOBALS['assunto'] = "informativo";
  14. $GLOBALS['email_remetente'] =  "web3.luv.wordpress.com";
  15. $GLOBALS['eng_arq'] = "eng2.html";
  16.  
  17. //--------------------------------------------------------------------
  18.  
  19. function menu(){
  20. system("command clear");
  21. $menu="Ex: php script --assunto='Asunto do envio' --remetente='email@remetente' --eng=envio.html\r
  22.     Ajuda: --ajuda\r
  23.     Remetente: --remetente='seu remetente'\r
  24.     Assunto do envio: --assunto='assunto'\r
  25.     Eng: --eng=arquivo.html\r\n\r\n\r\n
  26.  
  27. ";
  28.  
  29.  
  30. return  $menu;
  31. }
  32.  
  33. function conectart(){
  34.     $host = 'IP.BANCO.MYSQL';
  35.     $user = 'root';
  36.     $senha = '102030';
  37.     $banco = 'test';
  38.  
  39.     $link = mysql_connect($host, $user, $senha);
  40.     $link = mysql_select_db($banco, $link);
  41. if (!$link) {
  42.         die('ERRO : '.mysql_error());
  43. }
  44. }
  45.  
  46. function msg($nome,$email,$cargo,$end,$data){
  47. if($GLOBALS['eng_arq'] != 'vazio'){
  48.     $eng = file_get_contents($GLOBALS['eng_arq']);
  49.     $eng = str_replace('NOME_ENG',$nome,$eng);
  50.     $eng = str_replace('EMAIL_ENG',$email,$eng);
  51.     $eng = str_replace('CARGO_ENG',$cargo,$eng);
  52.     $eng = str_replace('END_ENG',$end,$eng);
  53.     $eng = str_replace('DATA_ENG',$data,$eng);
  54. }
  55. return $eng;
  56.  
  57. }
  58.  
  59. function enviar($email,$assunto,$eng){
  60.  
  61.         $headers="From:Informativo <{$GLOBALS['email_remetente']}>\r\n";
  62.         $headers.="MIME-Version: 1.0\r\n";
  63.         $headers.= "X-Priority: 3 (Higuest)\r\n";
  64.         $headers.= "X-MSMail-Priority: High\r\n";
  65.         $headers.="Content-type: text/html; charset=iso-8859-1\r\n";
  66.         $headers.="X-Mailer: PHP/".phpversion()."\r\n";
  67.  
  68. if(filter_var($email, FILTER_VALIDATE_EMAIL)){
  69. if(mail($email,$assunto,$eng,$headers)){
  70.         echo $GLOBALS['cont_ok']++." - {$email} - [OK]ENVIADO!\r\n";
  71. }
  72. else{
  73.         echo $GLOBALS['cont_erro']++." - {$email} - [NO]ENVIADO!\r\n";
  74. }
  75. }
  76. else{
  77.  
  78.     echo $GLOBALS['cont_erro']++." - {$email} - EMAIL INVALIDO!\r\n";
  79. }
  80. }
  81.  
  82. function processo(){
  83.     echo "REMETENTE: {$GLOBALS['email_remetente']}\r\n";
  84.     echo "ENG: {$GLOBALS['eng_arq']}\r\n";
  85.     echo "ASSUNTO: {$GLOBALS['assunto']}\r\n\r\n";
  86.     conectart();
  87.     $result = mysql_query('SELECT * FROM envio');
  88.         if (!$result) {
  89.                 die('ERRO!:' . mysql_error());
  90. }
  91. while($escrever=mysql_fetch_array($result)){
  92.         $eng=msg($escrever['nome'],$escrever['email'],$escrever['cargo'],$escrever['end'],$escrever['data']);
  93.     echo enviar($escrever['email'],$GLOBALS['assunto'],$eng)."\r\n";
  94.     sleep(1);
  95. }
  96.     $GLOBALS['cont_ok']= $GLOBALS['cont_ok'] - 1;
  97.     $GLOBALS['cont_erro']= $GLOBALS['cont_erro'] - 1;
  98.     echo "TOTAL: {$GLOBALS['cont_ok']}\r\n";
  99.     echo "TOTAL ERRO: {$GLOBALS['cont_erro']}\r\n";
  100.  
  101. }
  102. echo menu();
  103. processo();
  104.    
  105. ?>