Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2011, 10:38
servidigital
 
Fecha de Ingreso: abril-2010
Mensajes: 182
Antigüedad: 14 años, 1 mes
Puntos: 8
enviar email con condicion

hola amigos
quiero enviar un email a unos 500 amigos don info de mi sitio entonces ya tengo me base de datos con los nombre y emails de ellos y en esta puse estado en donde 1 esta esta habilitado para enviarle el email y 0 q ya se le envio el email he trabajado en el codigo con ayuda de algunos amigos de este foro pero no he podido aun
cheque el codigo

Código PHP:
<?php require_once('../../../Connections/bb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
// AGREGA AQUÍ TU CONEXIÓN A *LA DB.

mysql_select_db($database_bb$bb);

// AQUÍ SQL PARA MOSTRAR REGISTROS CON ESTADO 1.
$query_envioemail "SELECT * FROM email WHERE estado = '1' ORDER BY id_email ASC LIMIT 5";
$envioemail mysql_query($query_envioemail$bb) or die(mysql_error());
$row_envioemail mysql_fetch_assoc($envioemail);
$totalRows_envioemail mysql_num_rows($envioemail);

while (
$row_envioemail=mysql_fetch_array) { //COMIENZO DEL WHILE

$estado =$row_envioemail['estado'];

if (
$estado == 1) {

$email $row_envioemail['name'];
$id $row_envioemail['id_email'];  
include_once(
'../funciones/php-mailer/class.phpmailer.php');


$mail= new PHPMailer();
$bodyeregi_replace("[\]",'',$body);

$mail->From "[email protected]";
$mail->FromName "xxxxx";
$mail->Subject "Tu boletin";
$mail->AltBody " Para ver el mensaje, por favor, utilice un visor de HTML de correo electrónico compatibles!"// optional, comment out and test

$mail->Body "aqui mi info";

$mail->AddAddress($row_envioemail['email']);

if (!
$mail->Send()) { 
echo 
'Fallo *envio mail'; *
//FIN DEL WHILE


?>

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>comando caducar</title>
</head>

<body>
</body>
</html>
<?php
mysql_free_result
($envioemail);}}}
?>
aun o me funciona la idea es trabajarlo con el crob job q cada 1hora trabaje y q envie 5 0 10 email
y q si se a envio que cambie su estado a 0

gracias