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]”;




hire best wordpress php css developer
Need Help? Hire me now!
I can help you in anything related to webdevelopment, including: HTML, CSS, PHP & MySql, WordPress (plugins & themes development, others), regular expressions, server management, etc.

Leave a Reply

Your email address will not be published.