Foros del Web » Programando para Internet » PHP »

Ayuda con funcion mail()

Estas en el tema de Ayuda con funcion mail() en el foro de PHP en Foros del Web. Hola amigos, disculpen que les moleste; tengo una página web, y luego de un registro quiero que se me envíe un correo de confirmación; pero ...
  #1 (permalink)  
Antiguo 12/02/2011, 09:11
 
Fecha de Ingreso: febrero-2010
Mensajes: 60
Antigüedad: 14 años, 2 meses
Puntos: 0
Ayuda con funcion mail()

Hola amigos, disculpen que les moleste; tengo una página web, y luego de un registro quiero que se me envíe un correo de confirmación; pero el problema es que sólo lo recibe en hotmail y en gmail, no aparece nada. El código es el siguiente:

Código PHP:
<?php 
    $remite_nombre 
"Admin"
    
$remite_email "[email protected]"// tu correo 
    
$asunto "Activación de cuenta "// Asunto (se puede cambiar) 
    
$random_hash md5(date('r'time())); 
    
$cabeceras "From: ".$remite_nombre." <".$remite_email.">\r\n"
    
$cabeceras $cabeceras."Mime-Version: 1.0\n"
    
$cabeceras $cabeceras."Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
               
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash?>  
Content-Type: text/plain; charset="utf-8" 
Content-Transfer-Encoding: 7bit

Hola, <?php echo $_POST['nombres'?>\r\n
Hace poco que te has registrado, con el nombre de usuario "<?php echo $_POST['usuario'?>".\r\n

  Gracias\r\n

-----------------------------------------------  \r
    Administration  *\r

   
--PHP-alt-<?php echo $random_hash?>  
Content-Type: text/html; charset="utf-8" 
Content-Transfer-Encoding: 7bit

<div style="background-color: #FFC; width: auto; padding: 20px; height: auto;" ><a href="www.yosantiagodechuco.com"><img style="margin-left: 50px; " src="http://acceso.yosantiagodechuco.com/imagenes/Logo.png" width="112" height="100" alt="" longdesc="http://www.yosantiagodechuco.com" /></a>
  <div style="-webkit-border-radius: 9px; -moz-border-radius: 10px; border-radius: 9px; background-color: #FFF; border: 1px dashed #CCC; padding: 20px; text-align: justify;" >
    <div style="height: 300px; width: 150px; padding:5px; float: right; margin-left: 20px; border: 1px dashed #666; "><img src="http://acceso.yosantiagodechuco.com/imagenes/Publicidad.png" width="150" height="300" alt="" longdesc="http://www.yosantiagodechuco.com" /></div>
    <div><h3>Hola, <?php echo $_POST['nombres'?>
    </h3>
    <p>
  Gracias,<br /><br /><br />
</p>
<div style="width:320px">
  <p align="center" style="color:#666">-----------------------------------------------<br />   
    <em>Administración </em><br />
    </p>
</div></div>
<hr align="center" size="1" />
<p style="font-size: small;">* Si  recibiste este mensaje por error, <strong>NO</strong> sigas el enlace, y simplemente ignora este mensaje. El código de confirmación sólo será válido durante unos días.</p>
</div></div>

--PHP-alt-<?php echo $random_hash?>--
<?php
$mensaje 
ob_get_clean();               
                
$enviar_email mail($_POST['correo'],'=?UTF-8?B?'.base64_encode($asunto).'?=',$mensaje,$cabeceras); 
?>
que lo adapte de http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

espero que me puedan ayudar, gracias de antemano.
  #2 (permalink)  
Antiguo 12/02/2011, 09:26
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Respuesta: Ayuda con funcion mail()

Vas a tener problemas de todo tipo con los CSS: primero no te los toma inline con style="" y despues los <p> en Yahoo!

Te dejo algo que hice:

Código PHP:
<?php

$msg 
="Mensaje de prueba";

$template = <<<EOF
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{title}</title>
<style type="text/css">
body { font-size: 12px; margin: 0; padding: 0; font-family: Georgia, Times New Roman, Times, serif; }
p { font-size: 14px; color: #333333; margin-top: 0px; margin-bottom: 12px; padding: 0; font-family: Arial, Helvetica, sans-serif; }
h1 { color: #fff; font-size: 21px; font-family: Arial, Helvetica, sans-serif; margin: 0; padding: 0; text-shadow: 1px 1px 1px #000; }
.content p { font-size: 14px; color: #333333; margin-top: 0px; margin-bottom: 12px; padding: 0; font-family: Arial, Helvetica, sans-serif; }
.header h1 { font-family: Arial, Helvetica, sans-serif; font-size: 42px; margin: 0; padding: 0; color: #0d2d42; text-shadow: 1px 1px 1px #fff; }
.footer p { font-size: 12px; color: #666; margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; }
ul { margin: 0; padding-left: 14px; line-height: 18px; list-style: disc; }
li { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #00ffff; font-weight: bold; margin: 0; padding: 0; }
</style>
</head>
<body style="margin: 0; padding: 0; background-color: #d8e7ea;" marginheight="0" topmargin="0" marginwidth="0" leftmargin="0">
{simple body}
</body>
</html>
EOF;

  
$to$_GET['to'];
  
$from$_GET['from'];
  
$subject "Bienvenida ".rand(20000,50000);


  
// To send HTML mail, the Content-type header must be set
  
$headers  'MIME-Version: 1.0' "\n";
  
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\n";

  
// Additional headers
  //$headers .= "To: $to" . "\r\n";
  
  
$headers .= "From: $from" "\n";
            
$msg "Hola amigo<p/>Como estas ? este es un correo de notificacion ";
  
  
  
  
$msg str_replace('{simple body}',$msg,$template);
  
$msg str_replace('{title}','Pagina de prueba',$msg);
  
  echo 
$msg;
  
  
//Mail it
  //echo "FROM: $from<br/>TO: $to<br/>SUBJECT: $subject<p/>$msg";
  
$e mail($to$subject$msg$headers);
  
var_dump ($e); 


?>
__________________
Salu2!

Etiquetas: funcion, mail
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:05.