Changeset 2283


Ignore:
Timestamp:
Mar 18, 2008, 10:58:48 PM (16 years ago)
Author:
rub
Message:

Resolved issue 0000815: Email format standardization

Location:
branches/branch-1_7
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_7/admin/include/functions_notification_by_mail.inc.php

    r2060 r2283  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    201201    // Init mail configuration
    202202    $env_nbm['email_format'] = get_str_email_format($conf['nbm_send_html_mail']);
    203     $env_nbm['send_as_name'] = ((isset($conf['nbm_send_mail_as']) and !empty($conf['nbm_send_mail_as'])) ? $conf['nbm_send_mail_as'] : $conf['gallery_title']);
     203    $env_nbm['send_as_name'] = ((isset($conf['nbm_send_mail_as']) and !empty($conf['nbm_send_mail_as'])) ? $conf['nbm_send_mail_as'] : get_mail_sender_name());
    204204    $env_nbm['send_as_mail_address'] = get_webmaster_mail_address();
    205205    $env_nbm['send_as_mail_formated'] = format_email($env_nbm['send_as_name'], $env_nbm['send_as_mail_address']);
  • branches/branch-1_7/include/class_smtp_mail.inc.php

    r2105 r2283  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    122122      $this->server_parse('250');
    123123
    124       $to_header = 'To: ';
     124      if (preg_match('/^\s*to\s*:.*/mi', $headers) === 0)
     125      {
     126        $to_header = 'To: '.implode(',', array_map(create_function('$email','return "<".$email.">";'), $recipients));
     127      }
     128      else
     129      {
     130        $to_header = '';
     131      }
    125132
    126133      @reset($recipients);
     
    129136        $this->server_write('RCPT TO: <'.$email.'>'."\r\n");
    130137        $this->server_parse('250');
    131 
    132         $to_header .= '<'.$email.'>, ';
    133138      }
    134139
     
    136141      $this->server_parse('354');
    137142
    138       $this->server_write('Subject: '.$subject."\r\n".$to_header."\r\n".$headers."\r\n\r\n".$message."\r\n");
     143      $this->server_write('Subject: '.$subject."\r\n".(empty($to_header) ? "" : $to_header."\r\n").$headers."\r\n\r\n".$message."\r\n");
    139144      $this->server_write('.'."\r\n");
    140145      $this->server_parse('250');
  • branches/branch-1_7/include/config_default.inc.php

    r2105 r2283  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    268268$conf['send_bcc_mail_webmaster'] = false;
    269269
    270 // enabled_format_email:
    271 //  on true email will be formatted with name and address
    272 //  on false email will be only address
    273 // There are webhosting wich not allow email formatted (Lycos, ...)
    274 $conf['enabled_format_email'] = true;
    275 
    276270// default_email_format:
    277271//  Define the default email format use to send email
    278272//  Value could be text/plain  or text/html
    279273$conf['default_email_format'] = 'text/html';
     274
     275// define the name of sender mail:
     276// If value is empty, gallery title is used
     277$conf['mail_sender_name'] = '';
    280278
    281279// smtp configuration
  • branches/branch-1_7/include/functions_mail.inc.php

    r2279 r2283  
    5353
    5454/*
     55 * Returns the name of the mail sender :
     56 *
     57 * @return string
     58 */
     59function get_mail_sender_name()
     60{
     61  global $conf;
     62
     63  return (empty($conf['mail_sender_name']) ? $conf['gallery_title'] : $conf['mail_sender_name']);
     64}
     65
     66/*
    5567 * Returns an array of mail configuration parameters :
    5668 *
     
    8294  // name of the webmaster is the title of the gallery
    8395  $conf_mail['formated_email_webmaster'] =
    84     format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
     96    format_email(get_mail_sender_name(), $conf_mail['email_webmaster']);
    8597
    8698  $conf_mail['boundary_key'] = generate_key(32);
     
    97109function format_email($name, $email)
    98110{
    99   global $conf;
    100 
    101111  // Spring cleaning
    102112  $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email));
    103 
    104   if ($conf['enabled_format_email'])
    105   {
    106     // Spring cleaning
    107     $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name));
    108 
    109     if ($cvt_name!="")
    110     {
    111       $cvt_name = encode_mime_header(
    112                 '"'
    113                 .addcslashes($cvt_name,'"')
    114                 .'"');
    115       $cvt_name .= ' ';
    116     }
    117 
    118     if (strpos($cvt_email, '<') === false)
    119     {
    120       return $cvt_name.'<'.$cvt_email.'>';
    121     }
    122     else
    123     {
    124       return $cvt_name.$cvt_email;
    125     }
     113  $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name));
     114
     115  if ($cvt_name!="")
     116  {
     117    $cvt_name = encode_mime_header(
     118              '"'
     119              .addcslashes($cvt_name,'"')
     120              .'"');
     121    $cvt_name .= ' ';
     122  }
     123
     124  if (strpos($cvt_email, '<') === false)
     125  {
     126    return $cvt_name.'<'.$cvt_email.'>';
    126127  }
    127128  else
    128129  {
    129     return $cvt_email;
    130   }
     130    return $cvt_name.$cvt_email;
     131  }
     132}
     133
     134/**
     135 * Returns an email address list with minimal email string
     136 *
     137 * @param string with email list (email separated by comma)
     138 */
     139function get_strict_email_list($email_list)
     140{
     141  $result = array();
     142  $list = explode(',', $email_list);
     143  foreach ($list as $email)
     144  {
     145    if (strpos($email, '<') !== false)
     146    {
     147       $email = preg_replace('/.*<(.*)>.*/i', '$1', $email);
     148    }
     149    $result[] = trim($email);
     150  }
     151
     152  return implode(',', $result);
    131153}
    132154
     
    508530 *
    509531 * @param:
    510  *   - to: receiver(s) of the mail.
     532 *   - to: receiver(s) of the mail (list separated by comma).
    511533 *   - args: function params of mail function:
    512534 *       o from: sender [default value webmaster email]
     
    547569  }
    548570
    549   if (!empty($to))
    550   {
    551     $to = format_email('', $to);
    552   }
    553 
    554571  if (empty($args['from']))
    555572  {
     
    598615  {
    599616    $headers.= 'To: undisclosed-recipients: ;'."\n";
     617  }
     618  else
     619  {
     620    $headers.= 'To: '.$to."\n";
    600621  }
    601622
     
    728749    trigger_event('send_mail',
    729750      false, /* Result */
    730       trigger_event('send_mail_to', $to),
     751      trigger_event('send_mail_to', get_strict_email_list($to)),
    731752      trigger_event('send_mail_subject', $cvt_subject),
    732753      trigger_event('send_mail_content', $content),
Note: See TracChangeset for help on using the changeset viewer.