Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/03/2008, 23:12
Avatar de EmaD
EmaD
 
Fecha de Ingreso: marzo-2008
Mensajes: 93
Antigüedad: 16 años, 1 mes
Puntos: 2
Un problemita con funcion mail()

El problemqa e sel siguiente , tengo un formulario qeu llam a auna pagina recomendar.php.

Código:
<form action="recomendar/recomendar.php" method="post">
<input type="hidden" name="url" value="<? echo $_SERVER['HTTP_REFERER']; ?>">
<center>
  <span class="style1">Recomenda Esto a un amigo</span>
</center>
<table width="100%" border="1" bgcolor="#484848">
  <tr>
    <td width="50%">
      <div align="center">Tus Datos:</div></td>
    <td width="50%"><div align="center">Datos De tu Amigo:<br>
    </div></td>
  </tr>
  <tr>
    <td><div align="center">Tu Nombre: 
      <input type="text" name="tunombre">
    </div></td>
    <td>
      <div align="center">Su Nombre: 
      <input type="text" name="sunombre">
    </div></td>
  </tr>
  <tr>
    <td><div align="center">&nbsp;Tu Email: 
        <input type="text" name="tuemail">
      </div></td>
    <td><div align="center">&nbsp;Su Email: 
      <input type="text" name="suemail">
    </div></td>
  </tr>
  <tr>
  <td><div align="center">
    &nbsp;
  </div></td>
   <td><div align="center">
    <input type="submit" name="enviar" value=" Enviar ">
  </div></td>
  </tr>
</table>

recomendar.php

Código PHP:
<?php
if (isset($_POST['url']) && isset($_POST['enviar'])){
$url_recomendado$_SERVER['HTTP_REFERER'];
$redireccion=$_SERVER['HTTP_REFERER'];
//para el envío en formato HTML
// Para enviar correo HTML, la cabecera Content-type debe definirse
$headers  'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
//dirección del remitente
$headers .= 'From: Recomendados Radiometal <[email protected]>' "\r\n";
//dirección de respuesta, si queremos que sea distinta que la del remitente
$headers .= "Reply-To: [email protected]\r\n";
//el que envia
$tuemail $_POST['tuemail'];
$tunombre $_POST['tunombre'];

// el que recibe
$sunombre $_POST['sunombre'];
$suemail $_POST['suemail'];

$asunto "Hola, " .$sunombre" Tu amigo, ".$tunombre." Te Recomendo Esto..." ;
$mensaje"Hola, " .$sunombre"\r\n Tu amigo " .$tunombre."\r\n Te recomendo visitar el siguiente enlace \r\n\r\n Click En El Enlace Para ingresar\r\n" .$url_recomendado."\r\n" ;
mail($suemail,$asunto,$mensaje,"MIME-Version: 1.0 \r\n Content-type: text/html; charset=iso-8859-1 \r\n From: [email protected]\r\nContent-type: text/html\r\n");
header("Location: $redireccion");
}
// 
?>
Todo lindo , funciona barbaro , salvo uno sproblemas .

Po rejemplo si uso





Código PHP:
mail($suemail,$asunto,$mensaje,"MIME-Version: 1.0 \r\n Content-type: text/html; charset=iso-8859-1 \r\n From: [email protected]\r\nContent-type: text/html\r\n"); 

M ellega el correo en formato html y sel link se ve barbaro con los saltos de line ay todo. Pero el correo sale con el nomrbe del servidor y no con [email protected] como deberia llegar.


Opcion 2 usar los $headers qu eestan ahi

Código PHP:
$headers  'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
//dirección del remitente
$headers .= 'From: Recomendados miweb<[email protected]>' "\r\n";
//dirección de respuesta, si queremos que sea distinta que la del remitente
$headers .= "Reply-To: [email protected]\r\n"

Ose al funcoin mail quedarisa asi.

Código PHP:
mail($suemail,$asunto,$mensaje,$headers
Asi me llega el correo con la direccion de [email protected], pero no me muestra el mail en html .

Alguna ayuda?

Debe ser algo fasil pero h eintentado con distintos headers y distintas formas y weno hast aahor aconsegui eso y no se por que.


Salu2