Ignore:
Timestamp:
Feb 14, 2007, 11:53:04 PM (17 years ago)
Author:
rub
Message:

My last improvements before 1.7.0RC1.

Can include Cc & Bcc on mail.
Send mail to all administrators on new comment or new users.
Add validate link on new comment mail.
Try to detect if the NBM complementary content is HTML or plain text. With plain text, this content is convert to readable HTML.

File:
1 edited

Legend:

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

    r1809 r1818  
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    55// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    6 // | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net              |
     6// | Copyright (C) 2006-2007 Ruben ARNAUD - team@phpwebgallery.net         |
    77// +-----------------------------------------------------------------------+
    88// | branch        : BSF (Best So Far)
     
    2727// +-----------------------------------------------------------------------+
    2828
    29 /**
    30  * - Extract mail fonctions of password.php
    31  * - Modify pwg_mail (add pararameters + news fonctionnalities)
    32  * - Var conf_mail, function get_mail_configuration, format_email, pwg_mail
    33  */
    34 
    3529// +-----------------------------------------------------------------------+
    3630// |                               functions                               |
     
    10094
    10195/**
    102  * Return an completed array template/theme
     96 * Returns an completed array template/theme
    10397 * completed with $conf['default_template']
    10498 *
     
    162156
    163157/**
     158 * Returns email of all administrator
     159 *
     160 * @return string
     161 */
     162function get_administrators_email()
     163{
     164  global $conf;
     165
     166  $result = array();
     167
     168  $query = '
     169select
     170  U.'.$conf['user_fields']['username'].' as username,
     171  U.'.$conf['user_fields']['email'].' as mail_address
     172from
     173  '.USERS_TABLE.' as U,
     174  '.USER_INFOS_TABLE.' as I
     175where
     176  I.user_id =  U.'.$conf['user_fields']['id'].' and
     177  I.status in (\'webmaster\',  \'admin\') and
     178  '.$conf['user_fields']['email'].' is not null
     179order by
     180  username
     181';
     182
     183  $datas = pwg_query($query);
     184  if (!empty($datas))
     185  {
     186    while ($admin = mysql_fetch_array($datas))
     187    {
     188      if (!empty($admin['mail_address']))
     189      {
     190        array_push($result, format_email($admin['username'], $admin['mail_address']));
     191      }
     192    }
     193  }
     194
     195  return $result;
     196}
     197
     198/**
    164199 * sends an email, using PhpWebGallery specific informations
    165200 *
     
    168203 *   - args: function params of mail function:
    169204 *       o from: sender [default value webmaster email]
     205 *       o Cc: array of carbon copy receivers of the mail. [default value empty]
     206 *       o Bcc: array of blind carbon copy receivers of the mail. [default value empty]
    170207 *       o subject  [default value 'PhpWebGallery']
    171208 *       o content: content of mail    [default value '']
     
    175212 *       o theme: template to use [default $conf['default_template']]
    176213 */
    177 //function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $infos_format = 'text/plain', $email_format = null)
    178214function pwg_mail($to, $args = array())
    179215{
     
    223259  }
    224260
     261  if ($conf_mail['send_bcc_mail_webmaster'])
     262  {
     263    $args['Bcc'][] = $conf_mail['formated_email_webmaster'];
     264  }
     265
    225266  if (($args['content_format'] == 'text/html') and ($args['email_format'] == 'text/plain'))
    226267  {
     
    233274  $headers = 'From: '.$args['from']."\n";
    234275  $headers.= 'Reply-To: '.$args['from']."\n";
     276
     277  if (!empty($args['Cc']))
     278  {
     279    $headers.= 'Cc: '.implode(',', $args['Cc'])."\n";
     280  }
     281
     282  if (!empty($args['Bcc']))
     283  {
     284    $headers.= 'Bcc: '.implode(',', $args['Bcc'])."\n";
     285  }
     286
    235287  $headers.= 'Content-Type: multipart/alternative;'."\n";
    236288  $headers.= '  boundary="---='.$conf_mail['boundary_key'].'";'."\n";
    237289  $headers.= '  reply-type=original'."\n";
    238290  $headers.= 'MIME-Version: 1.0'."\n";
    239 
    240   if ($conf_mail['send_bcc_mail_webmaster'])
    241   {
    242     $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
    243   }
    244291
    245292  $content = '';
Note: See TracChangeset for help on using the changeset viewer.