Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/02/2011, 11:03
drakoncr
 
Fecha de Ingreso: octubre-2009
Mensajes: 19
Antigüedad: 14 años, 6 meses
Puntos: 0
Busqueda usar vector para cc en PHPMailer

El problema que tengo es que quiero recorrer un vector que contien la lista del to y del cc pero em da un error simpled e invalid adress. los datos del to y cc son tomados de uan caja de texto. Si alguien tiene una idea de como hace el addcc dinamico sin usar base de datso. se los agradeceria un monton.

Código PHP:
<?php 
$a
=$_POST['title'];
$b=$_POST['to'];
$c=$_POST['cc'];
$d=$_POST['dear'];
$f=$_POST['url'];
$g=$_POST['IPB'];
$h=$_POST['IPRM'];
$i=$_POST['IPRF'];
$j=$_POST['MRMF'];
$k=$_POST['GC'];
$l=$_POST['OM'];
$m=$_POST['DD'];
$file=file_get_contents('mail_base.html');
$file=str_replace('#title#',$a,$file);
$file=str_replace('#dear#',$d,$file);
$file=str_replace('#url#',$f,$file);
$n=substr($a,0,9);
$file=str_replace('#wo#',$n,$file);
$file=str_replace('#u1#',$g,$file);
$file=str_replace('#u2#',$h,$file);
$file=str_replace('#u3#',$i,$file);
$file=str_replace('#u4#',$j,$file);
$file=str_replace('#u5#',$k,$file);
$file=str_replace('#u6#',$l,$file);
$file=str_replace('#u7#',$m,$file);
$a=$a." - Notification";
$to explode(","$b);
$cc=explode(","$c);
$nt=$to[0];
$nameto=explode("@",$nt);
$nameto1=ucwords(str_replace('.',' ',$nameto[0]));

require_once(
'include/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
  
$mail->Host       "mail.yourdomain.com"// SMTP server
  
$mail->SMTPDebug  2;                     // enables SMTP debug information (for testing)
  
$mail->SMTPAuth   true;                  // enable SMTP authentication
  
$mail->SMTPSecure "ssl";                 // sets the prefix to the servier
  
$mail->Host       "smtp.gmail.com";      // sets GMAIL as the SMTP server
  
$mail->Port       465;                   // set the SMTP port for the GMAIL server
  
$mail->Username   "XXXXX";  // GMAIL username
  
$mail->Password   "XXXXX";            // GMAIL password
  
$mail->AddReplyTo($nt,$nameto1);
  
$mail->AddAddress($nt,$nameto1);
$num count($to); // numero de elementos
for ($i=1$i $num$i++) {
$tn=$to[i];
$meto=explode("@",$tn);
$meto1=ucwords(str_replace('.',' ',$meto[0]));
$mail->AddAddress($tn,$meto1);
}

$num2 count($cc); // numero de elementos
for ($j=0$j $num2$j++) {
$ton=$cc[j];
$meto2=explode("@",$ton);
$meto3=ucwords(str_replace('.',' ',$meto2[0]));
echo 
$ton;
echo ,
$meto3
$mail
->AddAddress($ton,$meto3);
}
  
$mail->SetFrom('[email protected]''Starwood');
  
$mail->AddReplyTo('[email protected]''Starwood');
  
$mail->Subject $a;
  
$mail->AltBody 'To view the message, please use an HTML compatible email viewer!'// optional - MsgHTML will create an alternate automatically
  
$mail->MsgHTML($file);
  
$mail->Send();
  echo 
"Message Sent OK</p>\n";
} catch (
phpmailerException $e) {
  echo 
$e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo 
$e->getMessage(); //Boring error messages from anything else!
}
?>