|
To send an e-mail HTML with PHP |
|
|
|
To send an e-mail with PHP is very simple, we have only to use the function mail. But when we write code HTML in the body of the message, we receive this one like text and not like a web page, as we would like. This has easy solution, only we need to add the head "Content-type: text/html" in the e-mail and the code that we should send it will be interpreted as HTML. Let's see as:
<? php
$codigohtml ='
<html>
<head>
<title> E-mail HTML </title>
</head>
<body>
<to href = "http://www.webtaller.com"> to Go to WebTaller </to>
</body>
';
$email = 'pepito@grillo.com';
$asunto = 'E-mail HTML';
$cabeceras = "Content-type: text/html\r\n";
mail ($email, $asunto, $codigohtml, $cabeceras);
?>
Thus the e-mails that we send will be seen like a Web page. In the heads we can add other things, as for example if we want to specify the one who sends the e-mail we will do:
$cabeceras = "From: direccion@email.dom \r\nContent-type: text/html\r\n";
Thus the sender of the e-mail would be direccion@email.dom
For Alex. |