source: trunk/include/functions_mail.inc.php @ 1019

Last change on this file since 1019 was 1019, checked in by rub, 18 years ago

[NBM] Step 1: Create new include files with current notification/mail fonctions (with improvement)

File size: 4.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net              |
7// +-----------------------------------------------------------------------+
8// | branch        : BSF (Best So Far)
9// | file          : $RCSfile$
10// | last update   : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $
11// | last modifier : $Author: plg $
12// | revision      : $Revision: 958 $
13// +-----------------------------------------------------------------------+
14// | This program is free software; you can redistribute it and/or modify  |
15// | it under the terms of the GNU General Public License as published by  |
16// | the Free Software Foundation                                          |
17// |                                                                       |
18// | This program is distributed in the hope that it will be useful, but   |
19// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
20// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
21// | General Public License for more details.                              |
22// |                                                                       |
23// | You should have received a copy of the GNU General Public License     |
24// | along with this program; if not, write to the Free Software           |
25// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
26// | USA.                                                                  |
27// +-----------------------------------------------------------------------+
28
29// Extract mail fonctions of password.php
30// And Modify pwg_mail (add pararameters + news fonctionnalities)
31// And var conf_mail, function init_conf_mail, function format_email
32
33define('PHPWG_ROOT_PATH','./');
34include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
35
36// +-----------------------------------------------------------------------+
37// |                               functions                               |
38// +-----------------------------------------------------------------------+
39
40/*
41 * Initialization of global variable $conf_mail
42 */
43function init_conf_mail()
44{
45  global $conf, $conf_mail;
46
47  if (count($conf_mail) == 0)
48  {
49    $conf_mail['mail_options'] = $conf['mail_options'];
50    $conf_mail['send_bcc_mail_webmaster'] = ($conf['send_bcc_mail_webmaster'] == true ? true : false);
51    list($conf_mail['email_webmaster']) = mysql_fetch_array(pwg_query('select '.$conf['user_fields']['email'].' from '.USERS_TABLE.' where '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].';'));
52    $conf_mail['formated_email_webmaster'] = format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
53    $conf_mail['text_footer'] = "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
54  }
55
56  return true;
57}
58
59function format_email($name, $email)
60{
61  if (strpos($email, '<') === false)
62    return $name.' <'.$email.'>';
63  else
64    return $name.$email;
65}
66
67/**
68 * sends an email, using PhpWebGallery specific informations
69 */
70function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
71{
72  global $conf, $conf_mail;
73
74  $to = format_email('', $to);
75
76  if ($from =='')
77    $from = $conf_mail['formated_email_webmaster'];
78  else
79    $from = format_email('', $from);
80
81  $headers = 'From: '.$from."\n";
82  $headers.= 'Reply-To: '.$from."\n";
83  if ($conf_mail['send_bcc_mail_webmaster'])
84    $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
85
86
87  $options = '-f '.$from;
88
89  $content = $infos;
90  $content.= $conf_mail['text_footer'];
91
92  if ($conf_mail['mail_options'])
93  {
94    return mail($to, $subject, $content, $headers, $options);
95  }
96  else
97  {
98    return mail($to, $subject, $content, $headers);
99  }
100}
101
102// +-----------------------------------------------------------------------+
103// | Global Variables
104// +-----------------------------------------------------------------------+
105$conf_mail = array();
106
107init_conf_mail();
108
109?>
Note: See TracBrowser for help on using the repository browser.