Hola, por un lado tienes que usar la función mail de php para el envío del correo:
<?php// Texto del correo$msg = "Gracias por inscribirte en nuestra pagina web\nDesde ahora puedes participar";// usar wordwrap() si las líneas son muy largas$msg = wordwrap($msg,70);// enviar emailmail("tata@ejemplo.com","Confirmacion de inscripcion",$msg);?>
Por otro lado tienes que construir el cuerpo del correo. Para extraer el contenido desde un archivo html puedes hacerlo como se explica en la entrega "Extraer código fuente de página web con PHP. Leer archivos completos: file_get_contents y nl2br (CU00838B)" del curso http://aprenderaprogramar.com/index.php?option=com_content&view=category&id=70&Itemid=193
Ejemplo cómo construir un correo con html:
<?
//change this to your email.
$to = "m@aprenderaprogramar.com";
$from = "m2@aprenderaprogramar.com";
$subject = "Hola! Esto es un correo con HTML";
//begin of HTML message
$message = <<<EOF
<html>
<body bgcolor="#DCEEFC">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br>
<font color="red">Thanks Mohammed!</font> <br>
<a href="https://www.aprenderaprogramar.com/">* aprenderaprogramar.com</a>
</center>
<br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@maaking.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "El mensaje ha sido enviado...!";
?>
Otro ejemplo:
<?
//change this to your email.
$to = "m@aprenderaprogramar.com";
$from = "m2@aprenderaprogramar.com";
$subject = "Hola! Esto es un correo con HTML";
//begin of HTML message
$message = "<html>
<body bgcolor=\"#DCEEFC\">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br>
<font color=\"red\">Thanks Mohammed!</font> <br>
<a href=\"https://www.aprenderaprogramar.com/\">* aprenderaprogramar.com</a>
</center>
<br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
</body>
</html>";
//end of message
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@maaking.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "El mensaje ha sido enviado...!";
?>
Salu2
No te funciono o fueron a la carpeta de "SPAM".
<?php$caberas="FROM: correo@correo.com\r\n";// Texto del correo$msg = "Gracias por inscribirte en nuestra pagina web\nDesde ahora puedes participar";// usar wordwrap() si las líneas son muy largas$msg = wordwrap($msg,70);// enviar emailmail("tata@ejemplo.com","Confirmacion de inscripcion",$msg,$caberas);?>
En las cabeceras puedes especificar el FROM, si quieres que al responder vaya a otra cuenta y esas cosillas
Si no te llega a ningun lado podia ser que no estuviera correctamente configurado, eso seria revisar en el php.ini la seccion del "mail"
PHPMailer es una librería popular para el envío de correos electrónicos, que algunos programadores usan como alternativa al uso de la función mail(). No obstante para el envío de correos sencillos la función mail() es lo más sencillo. La función mail() requiere un servidor local de correo para que envíe los correos, mientras que PHPMailer puede usar un servidor no local (SMTP) por ejemplo gmail si tienes autenticación (usuario y password) para acceder a él.
Ejemplo de envío de correo desde servidor local usando phpMailer:
<?phprequire_once "vendor/autoload.php";//PHPMailer Object$mail = new PHPMailer;//From email address and name$mail->From = "from@yourdomain.com";$mail->FromName = "Full Name";//To address and name$mail->addAddress("recepient1@example.com", "Recepient Name");$mail->addAddress("recepient1@example.com"); //Recipient name is optional//Address to which recipient will reply$mail->addReplyTo("reply@yourdomain.com", "Reply");//CC and BCC$mail->addCC("cc@example.com");$mail->addBCC("bcc@example.com");//Send HTML or Plain Text email$mail->isHTML(true);$mail->Subject = "Subject Text";$mail->Body = "<i>Mail body in HTML</i>";$mail->AltBody = "This is the plain text version of the email content";if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { echo "Message has been sent successfully";}
Ejemplo de envío de correo desde servidor smtp (por ejemplo gmail):
<?phprequire_once "vendor/autoload.php";$mail = new PHPMailer;//Enable SMTP debugging. $mail->SMTPDebug = 3; //Set PHPMailer to use SMTP.$mail->isSMTP(); //Set SMTP host name $mail->Host = "smtp.gmail.com";//Set this to true if SMTP host requires authentication to send email$mail->SMTPAuth = true; //Provide username and password $mail->Username = "name@gmail.com"; $mail->Password = "super_secret_password"; //If SMTP requires TLS encryption then set it$mail->SMTPSecure = "tls"; //Set TCP port to connect to $mail->Port = 587; $mail->From = "name@gmail.com";$mail->FromName = "Full Name";$mail->addAddress("name@example.com", "Recepient Name");$mail->isHTML(true);$mail->Subject = "Subject Text";$mail->Body = "<i>Mail body in HTML</i>";$mail->AltBody = "This is the plain text version of the email content";if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { echo "Message has been sent successfully";}
Salu2