'; $headers['From'] = 'Moshe '; $to = 'weitzman@tejasa.com'; $return = drupal_mail_wrapper('project_issue_update', $to, 'sub', 'body', 'from_foo', $headers); var_dump($return); } // ********* End for testing ******** // Run this once for Production, or set in settings.php // variable_set('smtp_library', drupal_get_path('module', 'drupalorg'). '/drupalorg.mail.inc'); // Send issue mail via call to `sendmail` so we avoid using recipient in To: header function drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $headers) { // copied from drupal_mail() $mimeheaders = array(); foreach ($headers as $name => $value) { $mimeheaders[] = $name .': '. mime_header_encode($value); } $subject = mime_header_encode($subject); $body = str_replace("\r", '', $body); $mimeheaders = join("\n", $mimeheaders). "\n"; // The only mails that get special treatment are issue followups. if ($mailkey == 'project_issue_update') { $bin = '/usr/sbin/sendmail -i'; $recipient = escapeshellarg($to); $msg = "Subject: $subject\n"; $msg .= 'To: '. $headers['List-Id']. "\n"; $msg .= $mimeheaders; $msg .= $body; if ($handle = popen("$bin $recipient", 'w')) { fwrite($handle, $msg); pclose($handle); return TRUE; } else { return FALSE; } } else { return mail( $to, $subject, $body, $mimeheaders ); } }