HTML:
Código:
<!DOCTYPE html>
<head>
<title>form</title>
</head>
<html>
<body>
<form name="datos" action="envio.php" method="POST">
<table align="center" border=0>
<tr>
<td>nombre</td>
<td><input type="text" name="nombre" size=10></td>
</tr>
<tr>
<td>asunto</td>
<td><input type="text" name="asunto"></td>
</tr>
<tr>
<td>email</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Enviar">
</tr>
</table>
</form>
</body>
</html>
PHP:
Código:
<?php
require_once('PHPMailer-master/class.phpmailer.php');
$nom=$_POST['nombre'];
$asu=$_POST['asunto'];
$ema=$_POST['email'];
$mail = new PHPMailer();
$header = "Return-Path: micorreoein.com\n";
$header .= "X-Sender: micorreoein.com\n";
$header .= "From: This is my website <micorreoein.com>\n";
$header .= "X-Mailer:PHP 5.1\n";
$header .= "MIME-Version: 1.0\n";
$header .= 'From: alberto <micorreoein.com>' . "\r\n";
$header .= 'Cc: micorreoein.com' . "\r\n";
$header .= 'Bcc: micorreoein.com' . "\r\n";
$header .= "Reply-To: micorreoein.com\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/plain; method=REQUEST; charset=utf-8\n";
$header .= "Content-Transfer-Encoding: 8bit\n";
$header .= "Content-class: urn:content-classes:calendarmessage\n";
$body = "Prueba de envio ";
$mail->IsMail();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Mailer = "smtp";
$mail->Host = "bbbb.ffff.com";
$mail->Port = 587;
$mail->Username = "micorreoein.com";
$mail->Password = "*****";
$mail->Subject = $asu;
$mail->MsgHTML($body);
$mail->SetFrom('micorreoein.com');
$mail->AddReplyTo("micorreoein.com");
$mail->AddAddress($ema, $nom);
if(!$mail->Send($header)) {
echo 'Error al enviar mensaje ' . $mail->ErrorInfo;
}
else {
echo "Mensaje enviado";
}
?>
PD: es un ejemplo no os centreis en el html xDDD.