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

Last change on this file since 4045 was 4045, checked in by cljosse, 15 years ago

[mail_supervisor] Modification gestion reprise spam

File size: 7.1 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}
28if (!defined('MAILl_SUPERV_DIR')) define('MAILl_SUPERV_DIR' , basename(dirname(__FILE__)));
29if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
30
31function test_envoie($message,$group_name,$group_id)
32{
33    global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données,$args ;
34        $mailto=""; 
35       
36
37//==================================================================================
38if (!isset($infos_message))
39        {
40        $infos_message = "";
41        }
42if (!isset($erreur_message))
43        {
44        $erreur_message = '';
45        }
46if (!isset($mails_données))
47        {
48        $mails_données = Get_Datas();
49        }               
50if (!isset($conf_mail))
51  {
52        $conf_mail = get_mail_configuration();
53  }
54          if (isset($args))
55  { 
56    $infos_message=memo_var($args);
57  }else{
58        $args = array();
59        }
60//=====================================================================================================
61
62 
63
64 
65$groups=get_liste($group_id);
66
67 
68//=======================================================================================
69  if (count($groups) > 0)
70  {
71 //===========================================================
72        $args['Bcc']=$groups;
73        $args['from'] = $conf_mail['formated_email_webmaster'];
74        //==================================================================
75         $message_texte=sprintf(
76        l10n('message_texte %s %s %s %s'),
77        format_date( date("Y-m-d H:i:s")),
78                $group_name,
79                $message,
80                $args['from']
81        );     
82        //==================================================================
83        $message_html = $message_texte;
84
85       
86 //==========================================================================
87
88        $args['subject']="Plugin Piwigo TEST";
89        $args['content']=$message_html;
90        $ret= pwg_mail($mailto , $args); 
91               
92                 $infos_message .=    sprintf( l10n('An information email was sent to group "%s"'), $group_name ).'<br />';
93
94                 
95        }else{
96               $infos_message .=l10n('no_receiver_available') ;
97        }
98       
99}
100//===============================================================================================================
101function mail_attachement($args)
102{
103 global $infos_message,$erreur_message ,$conf,$user,$conf_mail,$mail_données ;
104
105    $mails_données = Get_Datas();
106          if (!isset($conf_mail))
107  {
108    $conf_mail = get_mail_configuration();
109  }
110
111
112
113                $nom ='piwigo_logo_sombre_214x100.png'; 
114                $fichier=PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png' ;
115                $typemime='image/jpeg';
116                               
117                $fd = fopen( $fichier, "r" ); 
118                $contenu = fread( $fd, filesize( $fichier ) ); 
119                fclose( $fd ); 
120                $piecejointe  = chunk_split(base64_encode($contenu)); 
121               
122               
123         $from=$args['from'];
124$to="";
125
126     $message_texte=sprintf(
127        l10n('message_texte %s %s %s'),
128        format_date( date("Y-m-d H:i:s")),
129                $to,
130                $from
131        );     
132               
133 
134        $message_html =         '<img src="'.PHPWG_ROOT_PATH.'admin/template/goto/theme/roma/images/piwigo_logo_sombre_214x100.png" />';
135         ob_start();   
136 
137        echo str_replace("\n","<br />",$message_texte);
138       
139         $message_html .= ob_get_contents()."\n";
140         //ob_flush();
141        ob_end_clean();
142
143       $limite=$conf_mail['boundary_key'];   
144                $headers =   date("Y-m-d H:i:s") ."\n"; 
145
146  //=======================================================================================
147                $headers = "From: ".$args['from']."\n";
148                $headers.= "Reply-To: ".$args['from']."\n";
149                $nb_destinataires=0;
150$destinataire = $conf_mail['email_webmaster'];
151
152 
153                if (!empty($args['Cc']))
154                {$nb_destinataires += count($args['Cc']);
155                 $to= explode(',', $args['Cc']);
156                 $headers       .= get_strict_email_list($to) ;
157                   
158                }
159                if (!empty($args['Bcc']))
160                {  $nb_destinataires += count($args['Bcc']); 
161            $to = implode(',', $args['Bcc']);
162            $headers    .= 'Bcc :'.get_strict_email_list($to)."\n" ;
163                   
164                }
165
166  $headers.= 'Content-Type: multipart/alternative;'."\n";
167  $headers.= '  boundary="---='.$limite.'";'."\n";
168  $headers.= '  reply-type=original'."\n";
169  $headers.= 'MIME-Version: 1.0'."\n";
170  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
171
172  //Le message en texte simple pour les navigateurs qui n'acceptent pas le HTML
173    $texte = "This is a multi-part message in MIME format.\n"; 
174       
175        $texte .= "-----=".$limite."\n"; 
176        $texte .= "Ceci est un message est au format MIME.\n"; 
177        $texte .= 'Content-Type: text/plain; charset="UTF-8"'."\n"; 
178        $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
179        $texte .= $message_texte ; 
180                $texte .= "\n\n"; 
181               
182                $texte .= "-----=".$limite."\n"; 
183        $texte .= 'Content-Type: text/html; charset="UTF-8"'."\n"; 
184        $texte .= 'Content-Transfer-Encoding: 8bit'."\n\n"; 
185        $texte .= $message_html; 
186        $texte .= "\n\n"; 
187         
188
189
190                $attachement = "-----=".$limite."\n"; 
191                $attachement .= "Content-Type: ".$typemime."; name=\"".$nom."\"\n"; 
192                $attachement .= "Content-Transfer-Encoding: base64\n"; 
193                $attachement .= "Content-Disposition: attachment; filename=\"".$nom."\"\n\n"; 
194                $attachement .= $piecejointe; 
195                $attachement .= "\n\n\n-----=".$limite."\n"; 
196
197
198  $ret=false;
199
200ob_start();
201
202    $ret= mail( $destinataire, $args['subject'], $texte.$attachement, $headers); 
203   $message =  ob_get_contents() ;
204        //ob_flush();
205   ob_end_clean();
206   if (($message)<>"") {
207   $erreur_message .=  $message ;
208   $infos_message =  "-------------------";
209   }
210
211   
212    return  $ret;
213 
214}
215
216 
217?>
Note: See TracBrowser for help on using the repository browser.