Ver Mensaje Individual
  #12 (permalink)  
Antiguo 16/10/2008, 15:04
samu22
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años, 1 mes
Puntos: 16
Respuesta: Newsletter diaria

hola donfalcone, yo hice un sistemita de envios de mail con la clase phpMailer, ayuda muchisimo para eso que tenes que hacer

te dejo el proceso que hice, lo otro es un formulario con un editor de texto que no te lo paso porque no esta andando bien, te comento que es lo que hice en la base de datos, tengo una tabla news_mailinglist con estos campos

Código PHP:
 idMailidInteresMailActiv 
y otra tabla news_interes con estos campos

Código PHP:
 idMailInteres_GeneralEventosCapacitacionesActualizacionesProductosFacturacionOportunidadesOfertas 
en el formulario podes elegir la categoria

Código PHP:
<?php
session_start
();
include_once 
'../funciones/generales.php';
include_once 
'../funciones/mailReplace.php';
include_once 
'../config.php';


    if(
$_POST['sendMail']=='enviando'){
        require_once(
"../htmlTags.php");
        include 
'../../style/template/avisoscli.php';
        include(
"../class.phpmailer.php");
        
        
$mail = new PHPMailer();
        
$mail->Mailer "smtp";
        
$body = new htmlTags();
        
$refer $_SERVER['HTTP_REFERER'];
        
        
        
$estilo $_POST['estiloSelect'];
        
$mails $_POST['component-select'];
        
$mails $_POST['opcionalMailing'];
        
$mensaje $_POST['Area'];
        
$subjet $_POST['subjet'];
        
$estilo 'beta'//hasta terminar la parte de desarrollos
        // generar una consulta segun el estilo para mandar 
        //determinar los parametros que van a ser fijos para el estilo ya sean fondos tipos de letras 
        
$mensaje str_replace('\"','"',$mensaje);
        
//$mensaje = titRep($mensaje);
        
$to $_POST['cc'];
        
$titulo $_POST['titulo'];
        
        
$grupoConces $_POST['conces'];
        
/***********************************************************************************
         *********************************************************************************** 
         *********************************************************************************** 
         *********************************************************************************** 
         *********************************************************************************** 
         *********************************************************************************** 
         ***********************************************************************************/
            
                
                
if($_SESSION['Plantillas']=='plant1'){
                    
$msg ChangeTemplate('default',$titulo,$mensaje);
                }else{
                
                    if(
$estilo == 'beta'){
                        
$link '<a href="http://algunSitio/down/instructivo.pdf">Descargar el Instructivo</a>';
                        
$msg ChangeTemplate('default',$titulo,$mensaje,$link);
                    }
                }
            
                
                
            if (
$_POST['autor']==''){
            
$mail->From "[email protected]";
            }else{
                
$mail->From $_POST['autor'];
            }
            
            
$mail->FromName 'Mira quien habla - Su empresa';
            
            
/***********************************************************************************
         *********************************************************************************** 
         *********************************************************************************** 
         *********************************************************************************** 
         ***********    comprobar los emails     ****************************************************** 
         *********************************************************************************** 
         ***********************************************************************************/
            
            
if($grupoConces!=''){
                
$i=0;
                
$sql ="SELECT mail FROM [TABLA] WHERE [CAMPOID]='".$grupoConces."'";
                
$res $DbConn->query($sql);
                while (
$arr $DbConn->fetchArray($res)){
                    
$mails[$i] = $arr;                    
                    
$i++;
                
                    }
                
$cant count($mails);
            }
          
             for(
$i=0;$i<$cant;$i++){
                    if(
$grupoConces==3){
                        
$mail->AddAddress($mails[$i][0]);
                    }
            }
            
            
            
          
           
// $mail->AddAddress('[email protected]');
                    
            
$mail->IsHTML(true); // set email format to HTML

            
$mail->Subject $subjet;
            
$mail->Body $msg;
            
$mail->AltBody "This is the body in plain text for non-HTML mail clients";
            
           
       if(!
$mail->Send())
            {
            echo 
"Message could not be sent. <p>";
            echo 
"Mailer Error: " $mail->ErrorInfo;
            
$error true;
            
$errorDat $mail->ErrorInfo;
            exit;
            }

        if(
$_POST['autor']!='[email protected]'){
            
$mailInform  = new PHPMailer();
            
$mailInform->From '[email protected]';
            
$mailInform->FromName 'Info server';
            
$mailInform->AddAddress($_POST['autor']);
            
            
$msg '<html>
                        <body>'
;
                if(
$error==true){$msg.='Ocurrio el siguiente error: '.$errorDat;}
                    
$msg.='Se completo la operacion con exito a los siguientes e-mails:</br>
                    '
;
                    for(
$i=0;$i<$cant;$i++){
                                
$msg.= '<b>'.$mails[$i][0]. '</b></br>';
                            }
                    
$msg.= '
                        </body>
                        </html>'
;
            
$mailInform->IsHTML(true);        
            
$mailInform->Subject 'Informe de recepcion';        
            
$mailInform->Body $msg;                        
            
$mailInform->Send();
            }
    
    echo 
"
    <script type=\"text/javascript\">
        function timedMsg()
        {
        var t=setTimeout(\"window.location='$refer'\",5000)
        }
        </script>"
;
    echo 
'<body onLoad="timedMsg()">
            <div align="center">
            <p><b>Mensaje enviado correctamente, en segundos recibira un email con la confirmacion de los resultados</b></p>'
;
    
    
        echo
        
'    
            <p><b>Redireccionando</b></p>
            </div>
        </body>
    '
;
           
           
    

    }


    
?>