Jump to content


Photo

Newsletter


  • Faça o login para participar
6 replies to this topic

#1 Pitanga

Pitanga

    Normal

  • Usuários
  • 102 posts
  • Sexo:Não informado
  • Localidade:Portugal
  • Interesses:Designer, Photoshop, Pixel Arte, ....

Posted 12/10/2004, 07:22

Tenho que mandar uma newsletter para mais de 6000 contactos, já coloquei na sequencia o set_time_limit(0), mas mesmo assim o servidor não aguenta...

o que eu queria saber era se existe algum comando que envie esses mails com pausa de 60 seg a cada 100 mails que ele enviar da minha base de dados.... e um comando pra mostrar no ecrã os mails que ja foram enviados.....

segue abaixo o código pra quem interessar...

<?php 
include("coneccao.php");

$mensagem = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jorge Galhispo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<meta http-equiv="Content-Type" content="application/x-shockwave-flash;">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(http://www.trigenius.pt/jorge/bg.png);
}
.texto{
	font-size: 11px;
	font-family:Verdana;
    color:#000066;
}	
.spam {
	color: #FFFFFF;
	font-size: 9;
}
a {
	color: #FFFFFF;
	font-size: 9;
}
-->
</style>
</head>
<body>
<table width="900"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="texto">
  <tr>
    <td><img src="http://www.trigenius.pt/jorge/head.png" width="900" height="98"></td>
  </tr>
  <tr>
    <td>
   <table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0" class="texto">
        <tr>
          <td></td>
        </tr>
        <tr>
          <td><p>Olá a todos!</p>
        <p>Depois de 2 semanas de descanso, aqui estou eu em forma e com muita força.
          Como já viram, o meu novo desafio chama-se <strong>TRIGÉNIUS</strong>.</p>
    </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="texto">
            <tr>
              <td valign="top" width="240"><img src="http://www.trigenius.pt/jorge/loja.jpg" width="240" height="210"></td>
              <td valign="top"><p><strong>BI TRIG&Eacute;NIUS</strong><br>
        Nome: TRIG&Eacute;NIUS - Sistemas Inform&aacute;ticos, LDA<br>
        Morada: Av. Beato Nuno, Ed. Anjo de Portugal, Loja BM - 2495-401 F&aacute;tima<br>
        Data de Nascimento: 1998<br>
        Validade: De muito boa sa&uacute;de, recomenda-se!<br>
        <img src="http://www.trigenius.pt/jorge/tel.png" width="11" height="9"> 249 534 468 <img src="http://www.trigenius.pt/jorge/fax.png" width="9" height="9"> 249 533 354 <img src="http://www.trigenius.pt/jorge/mail.png" width="12" height="9"> comercial@trigenius.pt</p>                  
  <p><strong>&Aacute;REAS DE NEG&Oacute;CIO DA TRIG&Eacute;NIUS:</strong><br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Software de Gest&atilde;o Comercial e Financeiro<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Software de Gest&atilde;o Hoteleira e Restaura&ccedil;&atilde;o<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Hardware, Redes e consum&iacute;veis<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Servi&ccedil;os de Assist&ecirc;ncia Pr&eacute; e p&oacute;s-venda<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Mobili&aacute;rio de escrit&oacute;rio<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Desenvolvimento e alojamento de p&aacute;ginas de Internet<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Forma&ccedil;&atilde;o Standard e espec&iacute;fica</p></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>A <strong>TRIG&Eacute;NIUS</strong> tem como objectivo o fornecimento e implementa&ccedil;&atilde;o de Sistemas de Informa&ccedil;&atilde;o, 
       adaptados às necessidades dos seus clientes. Assim, desenvolveu o <strong>TRIGISTO</strong>, programa inform&aacute;tico para Gest&atilde;o 
     Comercial e Financeira, abarcando a &aacute;rea comercial, contabilidade, imobilizado e sal&aacute;rios. Criou ainda parcerias espec&iacute;ficas 
     com produtores de hardware e software, visando responder da melhor forma as necessidades do mercado onde est&aacute; inserida.</td>
        </tr>






        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>A <strong>TRIG&Eacute;NIUS</strong> est&aacute; a comemorar 6 anos de actividade, conta com 19 colaboradores e tem o seu software implementado 
       em mais de 300 empresas da zona centro.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Na <strong>TRIG&Eacute;NIUS</strong> serei respons&aacute;vel pelo mercado empresarial e darei apoio na gest&atilde;o e organiza&ccedil;&atilde;o 
       da empresa.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Esperando que esta informa&ccedil;&atilde;o v&aacute; de encontro às suas expectativas, aguardo um contacto da vossa parte.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="texto">
            <tr>
              <td width="50%">
         <p>Atentamente;</p>
                  <p><strong>Jorge Galhispo</strong><br>
        Gestor PMEs<br>
        <img src="http://www.trigenius.pt/jorge/mail.png" width="12" height="9"> jorge.galhispo@trigenius.pt<br>
         <img src="http://www.trigenius.pt/jorge/tel.png" width="11" height="9"> Telf.: 91 736 2975</p></td>
              <td width="50%">
       <div align="right">    <img src="http://www.trigenius.pt/jorge/assistencia.png" width="450" height="104">
           </div></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="texto">
            <tr>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/Logo%20MSFT.gif" width="136" height="42"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/wintouch.jpg" width="80" height="80"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/ibm.png" width="108" height="58"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/trigisto.jpg" width="90" height="63"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/samsung.png" width="96" height="96"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/primavera.png" width="105" height="23"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/LogoFSC.gif" width="136" height="60"></div></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><img src="http://www.trigenius.pt/jorge/foot.png" width="900" height="63"></td>
  </tr>
  <tr>
    <td bgcolor="#000066"><span class="spam">Na&nbsp; trigenius respeitamos a sua privacidade. Se n&atilde;o desejar receber futuras comunica&ccedil;&otilde;es, por favor,&nbsp; envie mail para <a href="mailto:webmaster@abelha.net?subject=%20RETIRAR%20DA%20LISTA">webmaster@abelha.net</a> com assunto RETIRAR DA LISTA. </span></td>
  </tr>
</table>
</body>
</html>
';

echo "<strong>Relatório de Envio</strong><br><br>";
  $sql = "SELECT * FROM newsTestes";
  $query = mysql_query($sql,$coneccao);

  while($row = mysql_fetch_object($query)){
	$email = $row->email;
	$contacto = $row->contacto;
	$entidade = $row->entidade;

   if ($contacto == NULL){
     $att = $entidade;
   }else
    $att = $contacto;
  
  $assunto = "Quem é vivo sempre aparece!"; 
  $selectMail = "$email; ";
        echo "$email <br>";
  
  $headers .= "Content-Type: text/html; charset=iso-8859-15\n";
  $header  .= "Content-type: application/x-shockwave-flash";
     $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "From: mail Teste <teste@testes.pt>\r\n";      
   	 $headers .= "Bcc: $selectMail <$selectMail>\r\n";
   }

   set_time_limit(0);
   if (mail($selectMail, $assunto, $mensagem, $headers)){
     echo "Mensagens enviadas com sucesso!<p>";
   }else{
     echo "Por algum motivo a sua mensagem não foi enviada, tente novamente mais tarde...";
   }
?>


#2 Felipe Pena

Felipe Pena

    O temor do Senhor é o princípio da sabedoria

  • Ex-Admins
  • 6441 posts
  • Sexo:Masculino

Posted 12/10/2004, 07:26

Utilizando:
http://br.php.net/sleep
Felipe Pena
[...] ó terra, terra, terra; ouve a palavra do Senhor. — Jeremias 22:29

#3 acao11

acao11

    12 Horas

  • Usuários
  • 166 posts
  • Sexo:Não informado
  • Interesses:PHP, Java, Linux, C, Apache, CGI/Perl, JavaScript e Delphi.

Posted 12/10/2004, 07:38

$q_mail = mysql_query("SELECT * FROM `tabela_mail`");

while ($r_mail = mysql_fetch_assoc($q_mail))
{
sleep(10); // 10 segundos depois executa novamente
mail($r_mail[CONTATO], 'titulo', 'EMAIL', "Content-type: text/plain\n");
}

#4 Pitanga

Pitanga

    Normal

  • Usuários
  • 102 posts
  • Sexo:Não informado
  • Localidade:Portugal
  • Interesses:Designer, Photoshop, Pixel Arte, ....

Posted 12/10/2004, 12:15

Como é que eu faço para colocar o resultado de
$r_mail = mysql_fetch_assoc($q_mail)

em uma variavel para no comando mail eu colocar apenas a variavel?

#5 LucasMS

LucasMS

    Super Veterano

  • Usuários
  • 2076 posts
  • Sexo:Não informado

Posted 12/10/2004, 12:17

vc tem q ir no arquivo http.conf do apache e mudar o time_limit para um numero suficiente, 0 eh ilimitado ... o set_time_limit() do php nao funciona se o apache nao permitir

#6 Pitanga

Pitanga

    Normal

  • Usuários
  • 102 posts
  • Sexo:Não informado
  • Localidade:Portugal
  • Interesses:Designer, Photoshop, Pixel Arte, ....

Posted 12/10/2004, 12:27

É assim: meu problema é o seguinte

Tenho uma base de dados em mysql com mais de 6000 emails de clientes cadastrados e presciso enviar uma newsletter

o meu código está assim...
<style type="text/css">
<!--
.titulo {
	font-size: 36px;
	font-style: italic;
}
-->
</style>
<?php 
include("coneccao.php");

$html = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jorge Galhispo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<meta http-equiv="Content-Type" content="application/x-shockwave-flash;">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(http://www.trigenius.pt/jorge/bg.png);
}
.texto{
	font-size: 11px;
	font-family:Verdana;
    color:#000066;
}	
.spam {
	color: #FFFFFF;
	font-size: 9;
}
a {
	color: #FFFFFF;
	font-size: 9;
}
-->
</style>
</head>
<body>
<table width="900"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="texto">
  <tr>
    <td><img src="http://www.trigenius.pt/jorge/head.png" width="900" height="98"></td>
  </tr>
  <tr>
    <td>
   <table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0" class="texto">
        <tr>
          <td></td>
        </tr>
        <tr>
          <td><p>Olá a todos!</p>
        <p>Depois de 2 semanas de descanso, aqui estou eu em forma e com muita força.
          Como já viram, o meu novo desafio chama-se <strong>TRIGÉNIUS</strong>.</p>
    </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="texto">
            <tr>
              <td valign="top" width="240"><img src="http://www.trigenius.pt/jorge/loja.jpg" width="240" height="210"></td>
              <td valign="top"><p><strong>BI TRIG&Eacute;NIUS</strong><br>
        Nome: TRIG&Eacute;NIUS - Sistemas Inform&aacute;ticos, LDA<br>
        Morada: Av. Beato Nuno, Ed. Anjo de Portugal, Loja BM - 2495-401 F&aacute;tima<br>
        Data de Nascimento: 1998<br>
        Validade: De muito boa sa&uacute;de, recomenda-se!<br>
        <img src="http://www.trigenius.pt/jorge/tel.png" width="11" height="9"> 249 534 468 <img src="http://www.trigenius.pt/jorge/fax.png" width="9" height="9"> 249 533 354 <img src="http://www.trigenius.pt/jorge/mail.png" width="12" height="9"> comercial@trigenius.pt</p>                  
  <p><strong>&Aacute;REAS DE NEG&Oacute;CIO DA TRIG&Eacute;NIUS:</strong><br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Software de Gest&atilde;o Comercial e Financeiro<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Software de Gest&atilde;o Hoteleira e Restaura&ccedil;&atilde;o<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Hardware, Redes e consum&iacute;veis<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Servi&ccedil;os de Assist&ecirc;ncia Pr&eacute; e p&oacute;s-venda<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Mobili&aacute;rio de escrit&oacute;rio<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Desenvolvimento e alojamento de p&aacute;ginas de Internet<br>
                      <img src="http://www.trigenius.pt/jorge/burllet.gif"  width="10" height="10"> Forma&ccedil;&atilde;o Standard e espec&iacute;fica</p></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>A <strong>TRIG&Eacute;NIUS</strong> tem como objectivo o fornecimento e implementa&ccedil;&atilde;o de Sistemas de Informa&ccedil;&atilde;o, 
       adaptados às necessidades dos seus clientes. Assim, desenvolveu o <strong>TRIGISTO</strong>, programa inform&aacute;tico para Gest&atilde;o 
     Comercial e Financeira, abarcando a &aacute;rea comercial, contabilidade, imobilizado e sal&aacute;rios. Criou ainda parcerias espec&iacute;ficas 
     com produtores de hardware e software, visando responder da melhor forma as necessidades do mercado onde est&aacute; inserida.</td>
        </tr>






        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>A <strong>TRIG&Eacute;NIUS</strong> est&aacute; a comemorar 6 anos de actividade, conta com 19 colaboradores e tem o seu software implementado 
       em mais de 300 empresas da zona centro.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Na <strong>TRIG&Eacute;NIUS</strong> serei respons&aacute;vel pelo mercado empresarial e darei apoio na gest&atilde;o e organiza&ccedil;&atilde;o 
       da empresa.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Esperando que esta informa&ccedil;&atilde;o v&aacute; de encontro às suas expectativas, aguardo um contacto da vossa parte.</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="texto">
            <tr>
              <td width="50%">
         <p>Atentamente;</p>
                  <p><strong>Jorge Galhispo</strong><br>
        Gestor PMEs<br>
        <img src="http://www.trigenius.pt/jorge/mail.png" width="12" height="9"> jorge.galhispo@trigenius.pt<br>
         <img src="http://www.trigenius.pt/jorge/tel.png" width="11" height="9"> Telf.: 91 736 2975</p></td>
              <td width="50%">
       <div align="right">    <img src="http://www.trigenius.pt/jorge/assistencia.png" width="450" height="104">
           </div></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="texto">
            <tr>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/Logo%20MSFT.gif" width="136" height="42"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/wintouch.jpg" width="80" height="80"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/ibm.png" width="108" height="58"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/trigisto.jpg" width="90" height="63"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/samsung.png" width="96" height="96"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/primavera.png" width="105" height="23"></div></td>
              <td width="140"><div align="center"><img src="http://www.trigenius.pt/jorge/LogoFSC.gif" width="136" height="60"></div></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><img src="http://www.trigenius.pt/jorge/foot.png" width="900" height="63"></td>
  </tr>
  <tr>
    <td bgcolor="#000066"><span class="spam">Na&nbsp; trigenius respeitamos a sua privacidade. Se n&atilde;o desejar receber futuras comunica&ccedil;&otilde;es, por favor,&nbsp; envie mail para <a href="mailto:webmaster@abelha.net?subject=%20RETIRAR%20DA%20LISTA">webmaster@abelha.net</a> com assunto RETIRAR DA LISTA. </span></td>
  </tr>
</table>
</body>
</html>
';

// variáveis
$sql = "SELECT * FROM newsTestes";
$query = mysql_query($sql,$coneccao);

$assunto 	 = "Quem é vivo sempre aparece!";
$mensagem  = $html;

$headers .= "Content-Type: text/html; charset=iso-8859-15\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "From: Jorge Galhispo <jorge.galhispo@adadadasd.pt>\r\n";      
$headers .= "To: Jorge Galhispo <jorge.galhispo@safasfasfasfs.pt>\r\n";      
$headers .= "Bcc: $selectMail <$selectMail>\r\n";

$count = 1;
while ($row = mysql_fetch_assoc($query)){
  if(($count % 100) == 0){
    sleep(10);
  }
   
  if(mail($row[EMAIL], $assunto, $mensagem, $headers)){
    echo "Mensagem enviada para: ";
  }else{
    echo "Falha no envio da mensagem para: ";
  }

    echo "$row[email]<br>";

}

?>


Alguém tem alguma crítica ou sugestão do que devo fazer para que esse código funcione? é que já o mudei tantas vezes e nada funciona.... não sei o que está errado e onde estou errando.... peço encarecidamente que alguém com conhecimento em php leia o meu codigo e me diga onde esta errado...

#7 Klaus

Klaus

    @ ubuntu jaunty

  • Ex-Admins
  • 7924 posts
  • Sexo:Masculino
  • Localidade:127.0.0.1

Posted 12/10/2004, 13:12

Envie por remessa de 100 em 100, 500 em 500 então ué...

É só tu consultar o DB pegando os emails estrategicamente...

SELECT blablabla LIMIT 0, 500


SELECT blablabla LIMIT 500, 500


Klaus Paiva
Conheça também: Taperás




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq