Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02/03/2012, 21:50
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: envio de correo mediante phpMailer de consulta

Amigos no logro mostrar los datos de la consulta

que estoy haciendo mal

ayuda por favor



Código PHP:
Ver original
  1. $correo = $_POST['email'];
  2.  
  3.   require_once('phpMailer/class.phpmailer.php');
  4.   require_once("phpMailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  5.  
  6.   $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  7.   $mail->IsSMTP(); // telling the class to use SMTP
  8.   $mail->Host       = "smtp.live.com"; // SMTP server
  9.   $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
  10.   $mail->SMTPAuth   = true;                  // enable SMTP authentication
  11.   $mail->Host       = "smtp.live.com"; // sets the SMTP server
  12.   $mail->SMTPSecure = "tls";
  13.   $mail->Port       = 25;                    // set the SMTP port for the GMAIL server
  14.   $mail->Username   = "[email protected]"; // SMTP account username
  15.   $mail->Password   = "oscarydiana";        // SMTP account password
  16.   $mail->AddReplyTo('[email protected]', 'oscar');
  17.   $mail->AddAddress('[email protected]', 'oscar');
  18.   $mail->SetFrom('[email protected]', 'oscar');
  19.   $mail->AddReplyTo('[email protected]', 'oscar');
  20.   $mail->Subject = 'Recuperar Contraseña';
  21.   $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  22.  
  23.   $mensaje="<table width='100%' border='1' cellpadding='0' cellspacing='0' bordercolor='#E0ECFF' class='Estilo1'>
  24. <tr>
  25. <td width='113' height='22' valign='middle' background'grid3-hrow.gif' class='borexterior' id='oferta_1'><div align='center'><strong>Usuario</strong></div></td>
  26. <td width='104' valign='middle' background='grid3-hrow.gif' class='borexterior' id='oferta_2'><div align='center'><strong>Contraseña</strong></div></td>
  27. </tr>";
  28.  
  29.  $servidor = 'localhost';
  30. $bd = 'calendario';
  31. $usuario = 'postgres';
  32. $contrasenia = 'hoe798cs';
  33.    
  34. global $servidor, $bd, $usuario, $contrasenia;
  35. $db = new PDO('pgsql:host=' . $servidor . ';dbname=' . $bd, $usuario, $contrasenia);
  36.  
  37. $consulta = $db->prepare("SELECT * FROM usuario  WHERE correo = '".$correo."'");
  38. $consulta->execute();
  39.  
  40.   while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
  41.     {
  42.  //$cuenta=$fila['cuenta'];
  43.  //$contasena=$fila['contrasena'];
  44.  $mensaje.="<tr align='center'>
  45. <td bordercolor='#E0ECFF' bgcolor='#FFFFFF'>".$fila['cuenta']."</td>
  46. <td bordercolor='#E0ECFF' bgcolor'#FFFFFF'>".$fila['contrasena']."</td>
  47. </tr>
  48. </table>";
  49. }
  50.  
  51.    
  52.   $mail->Body = $mensaje;
  53.   $mail->Send();
  54.   echo "Message Sent OK<p></p>\n";