Foros del Web » Programando para Internet » PHP »

Como llamo documento html en body de phpmailer

Estas en el tema de Como llamo documento html en body de phpmailer en el foro de PHP en Foros del Web. HOLA, TENGO UN PROBLEMA, ESTE ES MI CODIGO QUE UTILIZO PARA ENVIAR UN CORREO Y AL MISMO TIEMPO ALMASENARLO, SOLO QUE EN EL CUERPO DEL ...
  #1 (permalink)  
Antiguo 11/12/2008, 16:05
Diegotopet
Invitado
 
Mensajes: n/a
Puntos:
Pregunta Como llamo documento html en body de phpmailer

HOLA, TENGO UN PROBLEMA, ESTE ES MI CODIGO QUE UTILIZO PARA ENVIAR UN CORREO Y AL MISMO TIEMPO ALMASENARLO, SOLO QUE EN EL CUERPO DEL MENSAJE QUIERO LLAMAR A UNA PAGINA HTML DE MI SERVIDOR, PERO ME MARCA ERROR AL USAR EL METODO INCLUDE DE PHP, ALGUIEN ME PUEDE AYUDAR, COMO HAGO PARA QUE EL CUERPO DEL MENSAJE SEA LLAMADO DE UN DIRECTORIO HTLM DE MI SERVISOR?


Código PHP:
<?php include("../db.php"); // este archivo contendrá nuestros datos de conexión a MySQL ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO subscribe_unsubscribe (nombre, apellido, email, boletin) VALUES (%s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['Apellido'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['radio'], "text"));
  
mysql_select_db($advent);
  
$Result1 mysql_query($insertSQL) or die(mysql_error());
  
$insertGoTo "Index.html";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
mysql_select_db($advent);
$query_Recordset1 "SELECT * FROM subscribe_unsubscribe";
$Recordset1 mysql_query($query_Recordset1) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
<?
   
//Es necesario que al menos halla una dirección de destino
   
$error="";

   if (
$enviar) {
      if ((!
$email) && (!$email2)) {
    
$error.="Debe indicar al menos una dirección de destino";
      }
   }
    if (
$enviar && !$error) {

      
//creamos un array que estará formado por las direcciones de destino
      
if ($email) {
    
$direcciones["direccion1"]=$email;
      }
      if (
$email2) {
    
$direcciones["direccion2"]=$email2;
      }
      
//pasamos a enviar el correo

      // primero hay que incluir la clase phpmailer para poder instanciar 
      //un objeto de la misma
      
require "includes/class.phpmailer.php";

      
//instanciamos un objeto de la clase phpmailer al que llamamos 
      //por ejemplo mail
      
$mail = new phpmailer();
      
//Definimos las propiedades y llamamos a los métodos 
      //correspondientes del objeto mail
      
      //explicamos que es un documento en html
      
$mail->isHTML(true);

      
//Con PluginDir le indicamos a la clase phpmailer donde se 
      //encuentra la clase smtp que como he comentado al principio de 
      //este ejemplo va a estar en el subdirectorio includes
      
$mail->PluginDir "includes/";

      
//Con la propiedad Mailer le indicamos que vamos a usar un 
      //servidor smtp                            
      
$mail->Mailer "smtp";

      
//Asignamos a Host el nombre de nuestro servidor smtp
      
$mail->Host "pop.directnic.com";
      
      
//Le indicamos que el servidor smtp requiere autenticación
      
$mail->SMTPAuth true;

      
//Le decimos cual es nuestro nombre de usuario y password
      
$mail->Username "[email protected]";
      
$mail->Password $emailpass;
      
      
//Indicamos cual es nuestra dirección de correo y el nombre que 
      //queremos que vea el usuario que lee nuestro correo
      
$mail->From "[email protected]";

      
$mail->FromName "Vallarta & Cabo Adventures";

      
//Asignamos asunto y cuerpo del mensaje
      //El cuerpo del mensaje lo ponemos en formato html, haciendo 
      //que se vea en negrita
      
$mail->Subject "Prueba de phpmailer";
  [
U]    $mail->Body "<b>[U]AQUI ES DONDE QUIERO NOMBRAR MI ARCHIVO HTML OSEA QUE QUIERO QUE LO TOME DE MIS DIRECTORIOS[/U][<b>"[/U];
      
//Definimos AltBody por si el destinatario del correo no admite 
      //email con formato html
      
$mail->AltBody ="Thank you for joining our e-Magazine! You will receive it on bi-monthly basis, full of travelers´ tips, news about our social web, tours, questions/answers and pictures. Feel free to participate and interact by sending us your comments, questions and suggestions. Also, if you are active on the social web, please leave your comments on the blog at our websites www.vallarta-adventures.com and www.cabo-adventures.com. If you are a Facebook user, you are very welcome to visit and join our groups Travel Vallarta Adventures and Travel Cabo Adventures. Enjoy your journey in our cyber space and feel free to contact me for questions, comments or further information. Thank you and have a nice day! Gracias y que tengas un buen día! Tom Van Brunschot Online Marketing & Social Web Coordinator - Vallarta & Cabo Adventures - [email protected] - 322.297.1212 ext.472 ";

      
//el valor por defecto 10 de Timeout es un poco escaso dado que voy a usar 
      //una cuenta gratuita y voy a usar attachments, por tanto lo pongo a 120  
      
$mail->Timeout=120;

      
//Indicamos el fichero a adjuntar si el usuario seleccionó uno en el formulario
      
if ($achivo !="none") {
    
$mail->AddAttachment($archivo,$archivo_name);
      }

      
//Indicamos cuales son las direcciones de destino del correo y enviamos 
      //los mensajes
      
reset($direcciones);
      while (list(
$clave$valor)=each($direcciones)) {
    
$mail->AddAddress($valor);

    
//se envia el mensaje, si no ha habido problemas la variable $success 
    //tendra el valor true
    
$exito $mail->Send();

    
//Si el mensaje no ha podido ser enviado se realizaran 4 intentos mas 
    //como mucho para intentar enviar el mensaje, cada intento se hara 5 s
    //segundos despues del anterior, para ello se usa la funcion sleep
     
$intentos=1
       while((!
$exito)&&($intentos<5)&&($mail->ErrorInfo!="SMTP Error: Data not accepted")){
       
sleep(5);
            
//echo $mail->ErrorInfo;
            
$exito $mail->Send();
            
$intentos=$intentos+1;                
       }
    
//La clase phpmailer tiene un pequeño bug y es que cuando envia un mail con
    //attachment la variable ErrorInfo adquiere el valor Data not accepted, dicho 
    //valor no debe confundirnos ya que el mensaje ha sido enviado correctamente
    
if ($mail->ErrorInfo=="SMTP Error: Data not accepted") {
       
$exito=true;
        }        
    if(!
$exito)
    {
       echo 
"Problemas al registrar su cuenta: ".$valor;
       echo 
"<br>".$mail->ErrorInfo;    
    }
    else
    {
       
//Mostramos un mensaje indicando las direccion de 
       //destino    
       
$mensaje="<p>Cuenta registrada:<br>";
       
$mensaje.=$valor." ";
       
$mensaje.="</p>";
            echo 
$mensaje;
    }
    
// Borro las direcciones de destino establecidas anteriormente
        
$mail->ClearAddresses();
    }
    echo 
"<a href='$PHP_SELF'> VOLVER AL FORMULARIO</a>";
   }
   else {
   
?>
  #2 (permalink)  
Antiguo 11/12/2008, 17:13
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Como llamo documento html en body de phpmailer

Código:
      $mail->Body = file_get_contents('directorio/archivo.txt');
Solo como comentario, la funcion file_get_contents no esta disponible para versiones antiguas de PHP.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 12/12/2008, 10:38
 
Fecha de Ingreso: abril-2008
Ubicación: bcn
Mensajes: 33
Antigüedad: 15 años, 11 meses
Puntos: 0
Respuesta: Como llamo documento html en body de phpmailer

quiza te ayude este enlace
http://www.experts-exchange.com/Soft..._23678157.html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:25.