Ver Mensaje Individual
  #25 (permalink)  
Antiguo 24/04/2012, 22:41
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Envio de correo a varios destinatarios con phpMailer

hola amigos

no he podido identificar el error de mi codigo este es mi codigo javascript

estoy enviando por post un array opciones

Código Javascript:
Ver original
  1. <script type='text/javascript'>
  2. $(document).on('ready',function() {
  3.                 $('#chk_todos').on('click', function() {
  4.                     $('input[type=checkbox]').each(function() {
  5.                         if ($(this).attr('name') == 'opcion[]') {
  6.                             if ($(this).attr('checked') != 'checked') {
  7.                                 $(this).attr('checked','checked');
  8.                             }else {
  9.                                 $(this).removeAttr('checked');
  10.                             }
  11.                         }
  12.                     });
  13.                 });
  14.                
  15.                 $('#enviar').on('click',function() {
  16.                     var arrayOpt = new Array;
  17.                     $('input[type=checkbox]').each(function() {
  18.                         if ($(this).attr('name') == 'opcion[]') {
  19.                             if ($(this).attr('checked') == 'checked') {
  20.                                 arrayOpt.push($(this).val());
  21.                             }
  22.                         }
  23.                     });
  24.                    
  25.                     $.ajax({
  26.                         url:'recibio.php',
  27.                         type:'post',
  28.                         data: 'opciones='+arrayOpt,
  29.                         success: function(datos) {
  30.                             //$('#respuesta').html(datos);
  31.                             //alert("Datos guardados, respuesta:");
  32.                         }
  33.                     });
  34.                    
  35.                    
  36.                     return false;
  37.                 });
  38.             });
  39.  
  40. </script>

en mi archivo recibi.php
aca recibo por post el array

y lo integro con el el phpMailer
Código PHP:
Ver original
  1. $destinatarios = explode(',',$_POST['opciones']);
  2. echo implode(",", $destinatarios);
  3.  
  4. require_once('phpMailer/class.phpmailer.php');
  5. require_once("phpMailer/class.smtp.php");
  6. $mail = new PHPMailer(true);
  7. $mail->IsSMTP();
  8. $mail->Host       = "smtp.live.com";
  9. $mail->SMTPDebug  = 2;
  10. $mail->SMTPAuth   = true;
  11. $mail->SMTPSecure = "tls";
  12. $mail->Port       = 25;
  13. $mail->Username   = "[email protected]";
  14. $mail->Password   = "***";
  15.  
  16. $mail->AddReplyTo('[email protected]', 'oscar');
  17.   foreach($_POST['opciones'] as $destinatarios) {
  18.  
  19.       $mail->addAddress($destinatarios);
  20.       //o bcc
  21.       $mail->addBcc($destinatarios);
  22. }
  23.   $mail->SetFrom('[email protected]', 'oscar');
  24. $mail->Subject = 'Mensaje de Prueba';

no se que estoy haciendo mal .