source: extensions/Mail_supervisor/include/function_test_send.php @ 4925

Last change on this file since 4925 was 4925, checked in by cljosse, 14 years ago

[Mail_supervisor] Fix Bug in SQL

File size: 7.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if ( !defined('PHPWG_ROOT_PATH')) 
25{
26  die('Hacking attempt!');
27}
28
29
30
31function test_envoie($message,$group_name,$group_id)
32{
33    global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données,$args,$lang ;
34        $mailto=""; 
35       
36 load_language('plugin.lang', MAIL_SUPERV_PATH);
37 
38//==================================================================================
39if (!isset($infos_message))
40        {
41        $infos_message = "";
42        }
43if (!isset($erreur_message))
44        {
45        $erreur_message = '';
46        }
47if (!isset($mails_données))
48        {
49        $mails_données = Get_Datas();
50        }               
51if (!isset($conf_mail))
52  {
53        $conf_mail = get_mail_configuration();
54  }
55          if (isset($args))
56  { 
57    $infos_message=memo_var($args);
58  }else{
59        $args = array();
60        }
61//=====================================================================================================
62
63 
64
65$groups=get_liste($group_id);
66
67 
68//=======================================================================================
69  if (count($groups) > 0)
70  {
71       $args['Bcc']=$groups;
72   }   else {
73       $mailto = $conf_mail['formated_email_webmaster']; 
74   } 
75   
76        $args['from'] = $conf_mail['formated_email_webmaster'];
77
78      if (function_exists('get_user_language_desc') and isset($message) and $message <> '')
79        $message = get_user_language_desc($message)."\n\n";
80 
81        //==================================================================
82         $message_texte=sprintf(
83        l10n('Sv_message_texte %s %s %s %s'),
84        format_date( date("Y-m-d H:i:s")),
85                $group_name,
86                $message,
87                $args['from']
88        );     
89        //==================================================================
90        $message_html = $message_texte;
91
92       
93 //==========================================================================
94
95        $args['subject']="Plugin Piwigo TEST";
96        $args['content']=$message_html;
97                $infos_message .="To :" . $mailto;
98               
99        $ret= pwg_mail($mailto , $args); 
100        if ( $group_name <> '' or $mailto <> '' )
101        {       
102                if ($group_name<>'') {
103                 $infos_message .=  '<br />'.  sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />';
104                        }
105                        if ($mailto <> '') {
106                                $infos_message .=  '<br />'.  sprintf( l10n('Sv_mail_sent_to'), $mailto ).'<br />';
107                                }
108                 
109        }else{
110               $infos_message .='<br />'.l10n('Sv_no_receiver_available') ;
111        }
112
113}
114//===============================================================================================================
115function mail_attachement($args)
116{
117 global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données,$lang ;
118
119    $mails_données = Get_Datas();
120          if (!isset($conf_mail))
121  {
122    $conf_mail = get_mail_configuration();
123  }
124
125 load_language('plugin.lang', MAIL_SUPERV_PATH);
126
127                $nom ='piwigo_logo_sombre_214x100.png'; 
128                $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ;
129                $typemime='image/jpeg';
130                               
131                $fd = fopen( $fichier, "r" ); 
132                $contenu = fread( $fd, filesize( $fichier ) ); 
133                fclose( $fd ); 
134                $piecejointe  = chunk_split(base64_encode($contenu)); 
135               
136               
137         $from=$args['from'];
138$to="";
139
140     $message_texte=sprintf(
141        l10n('Sv_message_texte %s %s %s'),
142        format_date( date("Y-m-d H:i:s")),
143                $to,
144                $from
145        );     
146               
147 
148        $message_html =         '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />';
149         ob_start();   
150 
151        echo str_replace("\n","<br />",$message_texte);
152       
153         $message_html .= ob_get_contents()."\n";
154         //ob_flush();
155        ob_end_clean();
156
157       $limite=$conf_mail['boundary_key'];   
158                $headers =   date("Y-m-d H:i:s") ."\n"; 
159
160  //=======================================================================================
161                $headers = "From: ".$args['from']."\n";
162                $headers.= "Reply-To: ".$args['from']."\n";
163                $nb_destinataires=0;
164$destinataire = $conf_mail['email_webmaster'];
165
166 
167                if (!empty($args['Cc']))
168                {$nb_destinataires += count($args['Cc']);
169                 $to= explode(',', $args['Cc']);
170                 $headers       .= get_strict_email_list($to) ;
171                   
172                }
173                if (!empty($args['Bcc']))
174                {  $nb_destinataires += count($args['Bcc']); 
175            $to = implode(',', $args['Bcc']);
176            $headers    .= 'Bcc :'.get_strict_email_list($to)."\n" ;
177                   
178                }
179
180  $headers.= 'Content-Type: multipart/alternative;'."\n";
181  $headers.= '  boundary="---='.$limite.'";'."\n";
182  $headers.= '  reply-type=original'."\n";
183  $headers.= 'MIME-Version: 1.0'."\n";
184  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
185
186  //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML
187    $texte = "This is a multi-part message in MIME format.\n"; 
188       
189        $texte .= "-----=".$limite."\n"; 
190        $texte .= "Ceci est un message est au format MIME.\n"; 
191        $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 
192        $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
193        $texte .= $message_texte ; 
194                $texte .= "\n\n"; 
195               
196                $texte .= "-----=".$limite."\n"; 
197        $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; 
198        $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
199        $texte .= $message_html; 
200        $texte .= "\n\n"; 
201         
202
203
204                $attachement = "-----=".$limite."\n"; 
205                $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 
206                $attachement .= "Content-Transfer-Encoding: base64\n"; 
207                $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 
208                $attachement .= $piecejointe; 
209                $attachement .= "\n\n\n-----=".$limite."\n"; 
210
211
212  $ret=false;
213
214ob_start();
215
216    $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); 
217   $message =  ob_get_contents() ;
218        //ob_flush();
219   ob_end_clean();
220   if (($message)<>"") {
221   $erreur_message .=  $message ;
222   $infos_message =  "-------------------";
223   }
224
225   
226    return  $ret;
227 
228}
229
230 
231?>
Note: See TracBrowser for help on using the repository browser.