Ignore:
Timestamp:
Mar 18, 2008, 11:02:33 PM (17 years ago)
Author:
rub
Message:

Resolved issue 0000815: Email format standardization

Merge branch-1_7 2282:2283 into BSF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_mail.inc.php

    r2280 r2284  
    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
     
    507529 *
    508530 * @param:
    509  *   - to: receiver(s) of the mail.
     531 *   - to: receiver(s) of the mail (list separated by comma).
    510532 *   - args: function params of mail function:
    511533 *       o from: sender [default value webmaster email]
     
    546568  }
    547569
    548   if (!empty($to))
    549   {
    550     $to = format_email('', $to);
    551   }
    552 
    553570  if (empty($args['from']))
    554571  {
     
    597614  {
    598615    $headers.= 'To: undisclosed-recipients: ;'."\n";
     616  }
     617  else
     618  {
     619    $headers.= 'To: '.$to."\n";
    599620  }
    600621
     
    720741    trigger_event('send_mail',
    721742      false, /* Result */
    722       trigger_event('send_mail_to', $to),
     743      trigger_event('send_mail_to', get_strict_email_list($to)),
    723744      trigger_event('send_mail_subject', $cvt_subject),
    724745      trigger_event('send_mail_content', $content),
Note: See TracChangeset for help on using the changeset viewer.