Cool PHP Mail Script

Created: September 17, 2014
Last Modified: March 26, 2019
Subscribe to Internet Tips and Tools Feed
f Share
G+ Share
in Share
P in it

Here are two simple functions to send email in PHP.

  1. Using standard PHP - php_mail($to, $message, $headers_array)
  2. Using PEAR with PHP - pear_mail($to, $message, $headers_array)

The standard PHP and the PEAR functions will send both a plaintext and an html email with this script. Note: says "If intending to send HTML or otherwise Complex mails, it is recommended to use the PEAR package". I have noticed myself, that if you send many emails at once using PHPs mail function without PEAR then most of the emails do not get sent. dlc_b


Downloaded 0 times.
Please make a donation to reveal the download link.

then unzip coolphpmail.php. Edit line 26 with your name and email address to test the sending to. Upload coolphpmail.php to your server and point your browser to coolphpmail.php. The script will detect that you are running the script directly and send two emails to your email address. One email using standard PHP mail() function and the other email using PEAR mail functions.

Check your email and see which functions worked or if both worked. Then to use coolphpmail.php in your own scripts include it with:


and then call it in your script with:

php_mail($to, $message, $headers_array)


pear_mail($to, $message, $headers_array)

depending on which one worked.

The $headers_array should be created as follows:

	$headers = array('From' => $from_email, 
			'Reply-To' => $replyto_email,
			'Subject' => $subject,
			'Cc' => $cc_email,
			'Bcc' => $bcc_email);

The variable $from and the optional variable $reply-to can be one of the following formats:
	John Smith <>	

The variable $to and the optional variables $cc_email and $bcc_email can be any of the following:,
	User <>
	User <>, Another User <>


3/26/2019 - Version 1.1 - Fixed "warning: undefined variable" if PHP is set to display warnings.

9/17/2014 - Version 1.0 - Cool PHP Mail Script created

Back to
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 2 comments.

Displaying first 50 comments.

1. Posted By: Wayne Dinkins - - December 15, 2018, 7:21 pm
I purchased the Speech recognition Anywhere, and it sounds interesting, but I cannot locate the information to activate. My PC indicates itis downloaded, but I have searched and cannot find how to use the program. Need some help. thank you

2. Posted By: Jeff - - December 15, 2018, 10:40 pm
Hi Wayne Dinkins,

It is a Chrome extension. It doesn't download, it just installs when you click on "Add to Chrome" button at the Chrome Web Store. If you already installed the trial version then it is the same icon on the toolbar in Chrome. Just make sure that you are signed into Chrome with the same Google account that you used to purchase the extension with and then it will know that you paid for the Full version.