PHP mail function
By Anuket Jain On 29 July 2015 In PHP
This PHP mail function script has the ability to send a plain text email message. There are much better and more advanced PHP scripts on the Internet, but I hope this example will help you to understand, how it’s possible to send an email message using some PHP code.
Using mail() to send a simple email:
<?php
mail("to@example.com", "The Subject", "The Message", null, "-from@example.com")
?>
Example:
<?php
mail("dennis.r@techoism.com", "Confirmation", "This is a confirmation Mail", null, "-fme@mydomain.com")
?>
Sending mail with extra headers:
<?php
ini_set('display_errors',true);
error_reporting(E_ALL);
if (mail("to@example.com", "The Subject", "The Message", null, "-from@example.com")) {
echo "email sent";
} else {
echo "email failed";
}
?>
Example:
<?php
ini_set('display_errors',true);
error_reporting(E_ALL);
if (mail("dennis.r@techoism.com", "Confirmation", "This is a confirmation Mail", null, "-fme@mydomain.com")) {
echo "email sent";
} else {
echo "email failed";
}
?>
No Responses
