Ver Mensaje Individual
  #48 (permalink)  
Antiguo 29/02/2012, 22:39
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: recuperar contraseña mediante un email de sistema de usuarios

amigos necesito hacer una consulta a la base de datos y enviarla por phpMailer

ya envio el correo con datos constantes pero necesito en el cuerpo del email los dato de la consulta


Código PHP:
Ver original
  1. $consulta = $db->prepare("SELECT * FROM usuario  WHERE correo = '".$correo."'");
  2. $consulta->execute();
  3.  
  4.  
  5. while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
  6.     {
  7.  $cuenta=$fila['cuenta'];
  8.  $contasena=$fila['contrasena'];
  9.  
  10. }
  11.  
  12. require_once('phpMailer/class.phpmailer.php');
  13. require_once("phpMailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  14.  
  15. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  16.  
  17. $mail->IsSMTP(); // telling the class to use SMTP
  18.  
  19.   try {
  20.      
  21.   $mail->Host       = "smtp.live.com"; // SMTP server
  22.   $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
  23.   $mail->SMTPAuth   = true;                  // enable SMTP authentication
  24.   $mail->Host       = "smtp.live.com"; // sets the SMTP server
  25.  
  26.   $mail->SMTPSecure = "tls";
  27.   $mail->Port       = 25;                    // set the SMTP port for the GMAIL server
  28.   $mail->Username   = "[email protected]"; // SMTP account username
  29.   $mail->Password   = "oscarydiana";        // SMTP account password
  30.   $mail->AddReplyTo('[email protected]', 'oscar');
  31.   $mail->AddAddress('[email protected]', 'oscar');
  32.   $mail->SetFrom('[email protected]', 'oscar');
  33.   $mail->AddReplyTo('[email protected]', 'oscar');
  34.   $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
  35.   $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  36.   $mail->MsgHTML("Hola <b>mundo</b>");
  37.   $mail->Send();
  38.   echo "Message Sent OK<p></p>\n";
  39. } catch (phpmailerException $e) {
  40.   echo $e->errorMessage(); //Pretty error messages from PHPMailer
  41. } catch (Exception $e) {
  42.   echo $e->getMessage(); //Boring error messages from anything else!
  43. }