Skip to content

Instantly share code, notes, and snippets.

@lordspace
Created January 4, 2014 08:31
Show Gist options
  • Select an option

  • Save lordspace/8253092 to your computer and use it in GitHub Desktop.

Select an option

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
<?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