Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
<?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
You can’t perform that action at this time.