+44 (791) 5698 086

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.



$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



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




Leave a Reply

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

Who are we?

Nabtron team includes web, desktop software and mobile apps developers along with SEO professionals.

We are available 24 hours, 7 days a week. Contact us now for anything you need!

Join our mailing list

Lets become friend :) What's your name & email?