We apologize for the interruption. However, seabreezecomputers.com has been offering free tools and downloads for many years. Unfortunately, server expenses are now starting to exceed revenue earned. If you appreciate the free tools and downloads at seabreezcomputers.com please consider making a donation.
Here are two simple functions to send email in PHP.
The standard PHP and the PEAR functions will send both a plaintext and an html email with this script. Note: php.net 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:
firstname.lastname@example.org John Smith <email@example.com>
The variable $to and the optional variables $cc_email and $bcc_email can be any of the following:
firstname.lastname@example.org email@example.com, firstname.lastname@example.org User <email@example.com> User <firstname.lastname@example.org>, Another User <email@example.com>
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