Re: crear un mail a partir de una consulta
| From: | Gerardo Benitez | Date: | Mon, 29 Dec 2008 15:00:41 +0000 |
| Subject: | Re: crear un mail a partir de una consulta | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-63682@lists.php.net to get a copy of this message | ||
Hola!
Html por email, no es buena idea, salvo que estes seguros que todos los
destinatarios tengan configurado su cliente para ver correo en formato html..
Si no estas seguro de eso lo mejor que es que trates de darle la mejor forma
posible a tu mail solo con texto.
De cualquier modo, en el mail con formato en html no vas a poder agregar los
headers, solo el body.
2008/12/26 <irantzu@dosalcubo.net>
> Hola amigos, feliz navidad!!!
>
> Tengo un problemita y es que a partir de una consulta en base de datos debo
> mostrar algo por pantalla y a su vez enviarlo por mail, el caso es que lo
> que muestro por pantalla y lo que llega por mail no se ve igual, voy a
> copiar el código a continuación haber si ustedes ven el fallo y un par de
> capturas de pantalla (documento adjunto) para que vean lo que pasa.
>
> <?php $cuerpo='
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>'?>
> <? $cuerpo.='<head>'?>
> <? $cuerpo.='<style type = "text/css">'?>
>
> <? $cuerpo.='.textonormal {'?>
> <? $cuerpo.=' font-family: Arial, Helvetica, sans-serif;'?>
> <? $cuerpo.=' font-size: 12px;'?>
> <? $cuerpo.=' color: #000000;'?>
> <? $cuerpo.=' text-transform: none;'?>
> <? $cuerpo.='}'?>
>
> <? $cuerpo.='.tituloprincipal {'?>
> <? $cuerpo.=' font-family: Arial, Helvetica, sans-serif;'?>
> <? $cuerpo.=' font-size: 16px;'?>
> <? $cuerpo.=' font-weight: bold;'?>
> <? $cuerpo.=' color: #669934;'?>
> <? $cuerpo.=' text-transform: none;'?>
> <? $cuerpo.='}'?>
>
> <? $cuerpo.='.negrita {'?>
> <? $cuerpo.=' font-family: Arial, Helvetica, sans-serif;'?>
> <? $cuerpo.=' font-size: 14px;'?>
> <? $cuerpo.=' font-weight: bold;'?>
> <? $cuerpo.=' color: #000000;'?>
> <? $cuerpo.='}'?>
>
>
> <? $cuerpo.= '</style>'?>
> <? $cuerpo.= '</head>'?>
> <? $cuerpo.='
> <body>
>
> <div id="capa_logo_gaztelan" style="position:absolute; left:2px; top:2px;
> width:148px; height:54px; z-index:2">
> <a href="http://www.gaztelan.org"
> target="_blank">
> <img
> src="http://www.gaztelan.org/guianavarra/imagenes/logoguia.gif"
> border="0">
> </a>
> </div>
>
> <div id="capa_titulo" style="position:absolute; left:149px; top:2px;
> width:350px; height:54px; z-index:2">
> <a href="http://www.guianavarra.org"><img
>
> src="http://www.gaztelan.org/guianavarra/imagenes/tituloguia.gif"
> border="0"></a>
> </div>
>
> <div id="lateral_izquierda" style="position:absolute; left:2px; top:56px;
> width:148px; height:496px; z-index:2">
> <img src="
>
> http://www.gaztelan.org/guianavarra/imagenes/latedecha.gif"
> width="148" height="550">
> </div>
> '?>
> <?
> $num=$_post["num"];
> $fecha1=$_POST["fecha1"];
> $fecha2=$_POST["fecha2"];
> include ("fecha_desc.php");
> include ("conexion.php");//me conecto con la base de datos
> $link=Conectarse();//fin de conexion//<br>
>
> $formatfecha1=formateo_fecha($fecha1);
> $formatfecha2=formateo_fecha($fecha2);
> ?>
>
> <? $cuerpo.='
> <table width="700" border="0">
> <tr>
> <td width="150"> </td>
> <td align="center">
> <span class="textonormal">Consultas de cambios
> realizados del '
> .$formatfecha1.' al '.$formatfecha2.'</span>
> </td>
> </tr>
> '?>
>
> <? $cuerpo.='
> <tr>
> <td width="150"> </td>
> <td>
> <br><br><span
> class="tituloprincipal">NAVARRA</span>
> </td>
> </tr>
> '?>
>
> <?
> $result = mysql_query( "select * FROM contenido where fecha>='.$fecha1.'
> and fecha<='.$fecha2.' and ubicacion='NAVARRA' order by fecha asc",
> $link);
>
> while ($row=mysql_fetch_array($result))
> {
> $num=$row["num"];
> $fecha=$row["fecha"];
> $formatfecha=formateo_fecha($fecha);
> ?>
>
> <? $cuerpo.='
> <tr>
> <td width="200"> </td>
> <td width="600">
> <ul>
> <li>
> <a
> href=
>
> http://www.gaztelan.org/guianavarra/ventana_cambiosfecha.php?num='.$num..<http://www.gaztelan.org/guianavarra/ventana_cambiosfecha.php?num=%27.$num.>
> '>
> <span
> class="textonormal">'.$row['titulo'].'</span>
> </a>
> </li>
> </ul>
> </td>
> <td align="right" width="100"><span
> class="negrita">'.$formatfecha.'</span></td>
> </tr>
> '?>
>
> <?
> }
> ?>
>
> <? $cuerpo.='
> </table>
> </div>
> </body>
> </html>
> '?>
>
> <?php
> $destinatario = "irantzu.leunda@vilau.net";
> $asunto = "Cambios en www.guianavarra.org";
>
> //para el envío en formato HTML
> $headers = "MIME-Version: 1.0\r\n";
> $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
> $headers .= "From: www.guianavarra.org
> <actualizacionesguia@gaztelan.org>\r\n";
>
> //dirección del remitente
> //$headers .= "From: Miguel Angel Alvarez <pepito@desarrolloweb.com>\r\n";
>
> //dirección de respuesta, si queremos que sea distinta que la del
> remitente
> //$headers .= "Reply-To: mariano@desarrolloweb.com\r\n";
>
> //direcciones que recibián copia
> //$headers .= "Cc: maria@desarrolloweb.com\r\n";
>
> //direcciones que recibirán copia oculta
> //$headers .= "Bcc: pepe@pepe.com,juan@juan.com\r\n";
> echo $cuerpo;
> mail($destinatario,$asunto,$cuerpo,$headers)
>
> ?>
>
>
>
>
>
> --
> PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Gerardo Benitez
---------------------
Desarrollo web - Sistemas web - Intranets
Webseficientes
http://www.webseficientes.com.ar