/[drupal]/contributions/modules/returnpath/returnpath.module
ViewVC logotype

Contents of /contributions/modules/returnpath/returnpath.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Fri Aug 29 08:41:21 2008 UTC (14 months, 4 weeks ago) by deciphered
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.6: +30 -17 lines
File MIME type: text/x-php
Cleanup and minor fixes
1 <?php
2 // $Id: returnpath.module,v 1.6 2007/05/22 22:21:59 budda Exp $
3
4 /**
5 * @file
6 * Resolve sendmail 'return-path' header in emails sent from server.
7 *
8 * This allows bounceback emails to be returned to the sender, rather
9 * than the server which originally relayed the mail.
10 *
11 * @author: Mike Carter <www.ixis.co.uk/contact>
12 */
13
14 /**
15 * Implementation of hook_help().
16 */
17 function returnpath_help($path, $arg) {
18 switch ($arg) {
19 case 'admin/modules#description':
20 return t('Correctly passes a return-path: header when processing email.');
21 }
22 }
23
24 /**
25 * Replaces the default user_mail() and adds the sendmail -f command to the PHP mail() call.
26 */
27 function drupal_mail_wrapper($message) {
28 unset($messages['headers']['From']);
29
30 $mimeheaders = array();
31 foreach ($message['headers'] as $name => $value) {
32 $mimeheaders[] = $name .': '. mime_header_encode($value);
33 }
34
35 // If no explicit Return-path set, use From header and add Return-Path.
36 $return_path = empty($message['headers']['Return-Path'])
37 ? $message['from']
38 : $message['headers']['Return-Path'];
39
40 return mail(
41 $message['to'],
42 mime_header_encode($message['subject']),
43 // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
44 // They will appear correctly in the actual e-mail that is sent.
45 str_replace("\r", '', $message['body']),
46 // For headers, PHP's API suggests that we use CRLF normally,
47 // but some MTAs incorrecly replace LF with CRLF. See #234403.
48 join("\n", $mimeheaders),
49 // Adds the sendmail -f command.
50 "-f". $return_path
51 );
52 }

  ViewVC Help
Powered by ViewVC 1.1.2