Site icon Nabtron

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=”someemail@somedomain.com”;
$email_subject=”the posted variables”;
$email_message=”Theinitial message”;
$headers = “From: Beacze\r\n”.
“Reply-To: developer@nabtron.com\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 = “someemail@domain.com”;
$subject = “nab 1”;
$txt = “Results: ” . print_r( $_POST, true );
$headers = “From: someemail@domain.com”;

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

?>

 

Exit mobile version