Envia correos con PHP

Categories: PHP - Tags: , ,

Enviar correos con PHP es sencillo, basta un solo comando “mail”, a continuación muestro un ejemplo incluyendo el formulario de contacto, el formulario esta sin hoja de estilos, en un nuevo post explicare como darle formato.

1
2
3
4
5
6
7
8
9
10
11
<form action="mailer.php" method="post"> <fieldset>
<legend>Contacto</legend>
<ul>
    <li><label>Nombre:</label>
<input name="fnombre" size="25" type="text" /></li>
    <li><label>Email:</label>
<input name="femail" size="25" type="text" /></li>
    <li><label>Mensaje:</label><textarea cols="30" rows="6" name="fmensaje"></textarea></li>
</ul>
</fieldset>
</form>

Y nuestro archivo mailer.php

1
2
3
4
5
6
7
8
9
10
$mensaje="";
$mensaje.="COntacto". "\n\n";
$mensaje.="Nombre: ".$_POST['fnombre']."\n";
$mensaje.="E-mail: ".$_POST['femail']."\n";
$mensaje.="Mensaje: ".$_POST['fmensaje']."\n";

$mail="mio@mail.com";
$subject="Contactenos";
mail($mail,$subject,$mensaje,"From: Contact&lt;".$_POST['femail']."&gt;");
?&gt;

Descarga todo el codigo aqui

Leave a Reply

Your email address will not be published. Required fields are marked *

*


five - 5 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>