PHP mail function (for sending $_POST or $_GET data from form or AJAX)

phpThis post is to give an example of simple PHP mail function.

The first one is a simple mail function with minimum elements in it. The second one is a theme for sending $_POST posted data via email.

 

<?php

$email_to=”[email protected]”;
$email_subject=”the posted variables”;
$email_message=”Theinitial message”;
$headers = “From: Beacze\r\n”.
“Reply-To: [email protected]\r\n'” .
“X-Mailer: PHP/” . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
echo “mail sent!”

?>

This one sends the data submitted to the page via POST or GET from the form from previous page or through AJAX

 

<?php

$to = “[email protected]”;
$subject = “nab 1”;
$txt = “Results: ” . print_r( $_POST, true );
$headers = “From: [email protected]”;

mail($to,$subject,$txt,$headers);

?>

 

Leave a Reply

Your email address will not be published.