Created January 4, 2014 08:31
-
-
Save lordspace/8253092 to your computer and use it in GitHub Desktop.
This function schedules an email by passing -odd parameters to sendmail. Those emails will be processed depending on: /etc/sysconfig/sendmail (using 1h) if sendmail is running all the time otherwise you may have to start sendmail via cron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This function schedules an email by passing -odd paramaters to sendmail. | |
| * Those emails will be processed depending on: /etc/sysconfig/sendmail (using 1h) | |
| * if sendmail is running all the time. | |
| * | |
| * @param string $email recipient | |
| * @param string $subject - subject | |
| * @param string $message - the message | |
| * @return bool | |
| * @author Slavi Marinov | http://orbisius.com | |
| */ | |
| function send_email($email, $subject, $message) { | |
| $host = empty($_SERVER['HTTP_HOST']) ? `hostname -f` : $_SERVER['HTTP_HOST']; | |
| $headers = "From: $host Mailer <mailer@$host>\r\n" . | |
| 'Reply-To: help@$host' . "\r\n" . | |
| 'X-Mailer: PHP/' . phpversion(); | |
| // -odd -> tells sendmail to queue the email | |
| $status = mail($email, $subject, $message, $headers, '-odd'); | |
| return $status; | |
| } | |
| ?> |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment