Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the codepen-embed-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/u577718808/domains/kwwd.co.uk/public_html/blog/wp-includes/functions.php on line 6114
Simple PHP Mailer Function – Katy's Code Bank

Simple PHP Mailer Function

Send an email with PHP – useful for a simple contact form


if (isset($_POST['submit'])) // Your submit button or a required form field
{		
	$EmailTo = 'youremail@yourdomain.com';
	$Subject = 'Contact From Your Website';
	$EmailFrom = $_POST['email'];
	$Message = $_POST['messagefield'];
	$headers = "From: ".$EmailFrom;

	if (mail($emailTo, $Subject, $Message, $headers)) 
	{
		echo 'Your Message Was Sent';
	} else 
	{
		echo 'Error: Unable to send activation email.';
	}
}
else
{
	// Invalid request type or form not sent yet
}
Disclaimer: The code on this website is provided "as is" and comes with no warranty. The author of this website does not accept any responsibility for issues arising from the use of code on this website. Before making any significant changes, ensure you take a backup of all files and do not work directly on a live/production website without thoughly testing your changes first.

Leave a Reply

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