source: sipes/modules_contrib/returnpath/returnpath.module @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 1.6 KB
Línea 
1<?php
2// $Id: returnpath.module,v 1.7 2008/08/29 08:41:21 deciphered 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 */
17function 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 */
27function 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}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.