source: plugins/enviar_email/enviar_email_articulo.html @ 7

Last change on this file since 7 was 7, checked in by guille, 17 years ago

plugin enviar mail para enviar los articulos

File size: 12.2 KB
Line 
1#CACHE{0}
2<BOUCLE_enviar_articulo(ARTICLES){id_article}>
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html dir="#LANG_DIR" lang="#LANG">
5
6<head>
7        <title>[Enviar artículo: (#TITRE|textebrut)]</title>
8       
9        <!-- Para los buscadores -->
10        <meta http-equiv="Content-Type" content="text/html; charset=#CHARSET" />
11        <meta name="robot" content="follow, index, all">
12        <meta name="revisit-after" content="1 days">
13        <meta name="generator" content="SPIP" />
14        [<meta name="description" content="(#INTRODUCTION|couper{150}|attribut_html)" />]
15        <meta name="keywords" content="">
16
17
18<style type="text/css">
19<!--
20
21h2 {
22        font-size:130%;
23        font-weight:bold;
24}
25
26.formulario {
27        background-color: white;
28        border: 0px solid silver;
29        font-family: Verdana, Arial, Helvetica, sans-serif;
30        font-size:75%;
31        margin-top:.9em;
32}
33       
34.campos {
35        width: 95%;
36        padding-left: 2px;
37        padding-right: 2px;
38        padding-top:1px;
39        padding-bottom:1px;
40        font-size: 110%;
41        color:#333333;
42        margin-bottom:.3em;
43        border:1px solid #B2BFCF;
44}
45       
46.spip_bouton {
47        padding: 0px;
48        border: 1px solid gray;
49        background-color: whitesmoke;
50        font-family: verdana,helvetica,arial,sans-serif;
51        color: #666666;
52        font-size: 100%;
53}
54-->
55</style>
56
57</head>
58
59<body style="border:0px; padding:0px; text-align:center">
60#NOM_SITE
61<?php
62if (!$HTTP_POST_VARS){
63
64// MUESTRA EL FORMULARIO
65?>
66
67<div style="width:95%; margin:auto;">
68  <form action="<?php $phpself; ?>" method="POST" enctype="multipart/form-data" class="formulario">
69        <h2 style="text-align:center; margin-bottom:.2em"><span style="text-decoration:underline">#NOM_SITE_SPIP</span><div style="font-weight:normal; font-size:80%; margin-top:.6em;">Enviar [la referencia de "<span style="font-weight:bold; font-style: italic">(#TITRE)</span>" ]por correo electrónico</div></h2>
70    <fieldset style="text-align:left; margin-bottom:.6em">
71   <b>Enviar a la dirección:</b><div style="font-size:95%;color:#999999">(separa con comas si escribes más de una)</div><input name="destino" class="campos" value="" size="40"></fieldset>
72       <fieldset style="text-align:left">
73       <legend style="font-weight:bold">Datos opcionales</legend>
74    Asunto <span style="font-size:95%;color:#999999">(título que quieres darle al mensaje)</span><br /><input name="asunto" class="campos" size="40" value=""><br/>
75      Tu nombre<br /><input name="nombre" class="campos" size="40" value=""><br/>
76     Tu dirección de correo electrónico<br /><input name="email" class="campos" size="40" value=""><br />
77     Puedes añadir un texto en el mensaje<br /><textarea name="coment" class="campos" style="font-size:100%; font-family:verdana, arial, helvetica, sans-serif;" cols="40" rows="3"></textarea>
78     <div style="text-align:center">
79      <input type="submit" name="enviar" class="spip_bouton" style="margin-top:.3em" value="Enviar">&nbsp;&nbsp;&nbsp;<input type="button"  class="spip_bouton" style="margin-top:.3em" value="Cancelar" onclick="window.close();"> 
80      </div>
81      <input type="hidden" name="message" value="1">
82      </fieldset>
83  </form> 
84</div>
85
86<?php
87}else{
88
89// REVISA QUE HAYA UN EMAIL PARA ENVIAR EL MENSAJE
90if (!$destino) { echo "<p style='color:red; font-size:90%'>Lo sentimos :-(, pero sin dirección de correo electrónico válida no podemos enviar el mensaje</p>";
91
92?>
93
94<div style="width:90%; margin:auto;">
95  <form action="<?php $phpself; ?>" method="POST" enctype="multipart/form-data" class="formulario">
96        <h2 style="text-align:center; margin-bottom:.2em"><span style="text-decoration:underline">#NOM_SITE_SPIP</span><div style="font-weight:normal; font-size:80%; margin-top:.6em;">Enviar [la referencia de "<span style="font-weight:bold; font-style: italic">(#TITRE)</span>" ]por correo electrónico</div></h2>
97    <fieldset style="text-align:left; margin-bottom:.6em">
98   <b>Enviar a la dirección:</b><div style="font-size:95%;color:#999999">(separa con comas si escribes más de una)</div><input name="destino" class="campos" value="" size="40"></fieldset>
99       <fieldset style="text-align:left">
100       <legend style="font-weight:bold">Datos opcionales</legend>
101    Asunto <span style="font-size:95%;color:#999999">(título que quieres darle al mensaje)</span><br /><input name="asunto" class="campos" size="40" value=""><br/>
102      Tu nombre<br /><input name="nombre" class="campos" size="40" value=""><br/>
103     Tu dirección de correo electrónico<br /><input name="email" class="campos" size="40" value=""><br />
104     Puedes añadir un texto en el mensaje<br /><textarea name="coment" class="campos" style="font-size:100%; font-family:verdana, arial, helvetica, sans-serif;" cols="40" rows="3"></textarea>
105     <div style="text-align:center">
106      <input type="submit" name="enviar" class="spip_bouton" style="margin-top:.3em" value="Enviar">&nbsp;&nbsp;&nbsp;<input type="button"  class="spip_bouton" style="margin-top:.3em" value="Cancelar" onclick="window.close();"> 
107      </div>
108     
109      <input type="hidden" name="message" value="1">
110     
111      </fieldset>
112  </form> 
113</div>
114<?php
115}else {
116
117// ENVÍO DEL MENSAJE CON PHPMAILER
118
119include_spip("phpmailer/class.phpmailer");
120include_spip("phpmailer/class.smtp");   
121include_spip('inc/meta'); // para coger datos automáticamente del servidor, usuario,...
122$mail = new PHPMailer();
123
124$mail->IsSMTP();
125$mail->Mailer = "mail";
126$mail->Host     = "localhost"; // Servidor de SMTP
127
128$mail->SetLanguage("es", "phpmailer/language/");
129$mail->CharSet  = lire_meta('charset');  // Juego de caracteres
130$mail->Timeout="20";
131
132$mail->WordWrap = "75";                                 // set word wrap to 50 characters
133//$mail->AddAttachment("/var/tmp/file.tar.gz");         // añadir archivos
134$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // añadir archivos con nombre
135
136// VARIABLES
137
138$un_salto="\r\n";
139$dos_saltos="\r\n\r\n";
140
141// PARTE COMÚN
142
143    //Estoy recibiendo los campos, compongo el cuerpo
144   
145    if (!$HTTP_POST_VARS["nombre"]) { $remite= "Olvidó escribir su nombre"; } else { $remite= $HTTP_POST_VARS["nombre"]; }
146    $mail->FromName = $remite; // de nombre
147    $mail->From = $HTTP_POST_VARS["nombre"]; // de email
148   
149        if (!$HTTP_POST_VARS["email"]) { $replica = "[(#EMAIL_WEBMASTER)]"; } else { $replica = $HTTP_POST_VARS["email"]; }
150        $mail->AddReplyTo($replica); // reply
151   
152    $separar = explode(',',$destino);
153        foreach($separar as $email_destino) {
154                $mail->AddAddress($email_destino); // para
155                };
156       
157    if (!$HTTP_POST_VARS["asunto"]) { $asunto="[(#TITRE|texte_script)]"; } else { $asunto=$HTTP_POST_VARS["asunto"]; }
158    $mail->Subject = $asunto; // Asunto
159
160// COMIENZO PARTE TEXTO PLANO
161
162//Referencia al artículo para el texto plano
163?>
164
165<B_autores>
166<BOUCLE_autores(AUTEURS){id_article}{", "}>
167<?php $autores='#NOM'; ?>
168</BOUCLE_autores>
169<?php $autores="|de ".$autores; ?>
170</B_autores>
171
172<?php
173        $articulo= "::: [(#TITRE|attribut_html)] :::".$un_salto;
174        $articulo.= "[(#SURTITRE|attribut_html)|][(#SOUSTITRE|attribut_html)|][(#DATE|affdate)]".$autores.$dos_saltos;
175        $articulo.= "[(#INTRODUCTION|attribut_html|textebrut|couper{360})]".$dos_saltos;
176
177        if (!$HTTP_POST_VARS["coment"]) { $comentario="Hola. Quizás este artículo de #NOM_SITE_SPIP (#URL_SITE_SPIP) te pueda interesar."; } else { $comentario=$HTTP_POST_VARS["coment"]; }
178    $texto_plano .= $dos_saltos.$comentario.$dos_saltos."-------------------------------".$dos_saltos;
179    $texto_plano .= $articulo;
180    ?>
181<B_documents_plano>
182<?php
183$texto_plano .="Si visitas el artículo podrás descargarte los siguientes documentos:".$un_salto;
184?>
185<BOUCLE_documents_plano(DOCUMENTS) {id_article} {mode=document} {doublons}>
186<?php
187$texto_plano .="[- #TITRE, (#TYPE_DOCUMENT - (#TAILLE|taille_en_octets))]".$dos_saltos;
188?>
189</BOUCLE_documents_plano>
190</B_documents_plano>
191
192<?php
193        $texto_plano.= "* leerlo completo: #URL_SITE_SPIP/#URL_ARTICLE".$un_salto;
194    $texto_plano .= $un_salto."-------------------------------".$un_salto."Mensaje enviado por: ".$remite." <".$replica.">".$un_salto;
195    $texto_plano .= "Fuente: #NOM_SITE_SPIP (#URL_SITE_SPIP)";
196    $texto_plano .= $un_salto."-------------------------------".$un_salto;
197   
198    $mail->AltBody = $texto_plano; //Cuerpo en TEXTO PLANO
199   
200// FIN PARTE TEXTO PLANO
201
202// COMIENZO PARTE HTML
203
204$texto_html .="<div style='margin:1.2em;background: #fff;font-family:\'Trebuchet MS\', Tahoma, Arial, Verdana,sans-serif;font-size: 0.9em;text-align: left;'>";
205        if (!$HTTP_POST_VARS["coment"]) { $comentario="Hola. Quizás este artículo de <a href='#URL_SITE_SPIP' style='text-decoration: none'>#NOM_SITE_SPIP</a> te pueda interesar."; } else { $comentario=$HTTP_POST_VARS["coment"]; }
206$texto_html .="<p>".$comentario."</p>";
207$texto_html .="<div style='border: 1px solid #ccc;padding: .5em;'>";
208$texto_html .="[<div style='font-size:1.1em;'><a href='#URL_SITE_SPIP/#URL_ARTICLE' style='text-decoration: none'>(#TITRE|supprimer_numero)</a></div>]";
209?>
210
211<B_autores_html>
212<BOUCLE_autores_html(AUTEURS){id_article}{", "}>
213<?php $autores='[<a href="#URL_SITE_SPIP/#URL_AUTEUR" style="text-decoration:none">(#NOM)</a>]'; ?>
214</BOUCLE_autores_html>
215<?php $autores=" / de ".$autores; ?>
216</B_autores_html>
217
218<?php
219$texto_html .="<div style='color:#666666; font-size:90%;padding-bottom:.3em'>[(#SURTITRE|attribut_html) / ][(#SOUSTITRE|attribut_html) / ][(#DATE|affdate)]".$autores."</div>";
220$texto_html .="<div style='font-size:96%'>[(#CHAPO|attribut_html)]</div>";
221$texto_html .="<div style='font-size:96%'>[(#TEXTE|attribut_html)]</div>";
222$texto_html .=" <div style='color:#999999; font-size:90%;'>[<a href='#URL_SITE_SPIP/#URL_ARTICLE' style='text-decoration: none'>... leer m&aacute;s &rsaquo;&rsaquo;&rsaquo;</a>]</div>";
223?>
224<B_documents>
225<?php
226$texto_html .="<div style='margin-top:.6em;padding:.3em; padding-bottom:0px;border-top:1px solid #cccccc;color:#666666; font-size:85%;'>Si visitas el artículo podrás descargarte los siguientes documentos:<br />";
227?>
228<BOUCLE_documents(DOCUMENTS) {id_article} {mode=document} {doublons}>
229<?php
230$texto_html .="[&bull; #TITRE, (#TYPE_DOCUMENT - (#TAILLE|taille_en_octets))]";
231?>
232</BOUCLE_documents>
233<?php
234$texto_html .="</div>";
235?>
236</B_documents>
237<?php
238$texto_html .="</div>";
239$texto_html .= "<div style='margin-top:.2em;margin-bottom:.9em;color:#666666; font-size:80%;text-align:right'>Mensaje enviado por: ".$remite." <".$replica.">";
240$texto_html .= " /// Fuente: <a href='#URL_SITE_SPIP' style='text-decoration: none'>#NOM_SITE_SPIP</a><br /></div>";
241$texto_html .="</div>";
242
243$mail->Body    = $texto_html; //Cuerpo en HTML
244
245// FIN PARTE HTML
246
247// Envío (5 intentos)
248$enviado = $mail->Send();
249$intentos=1;
250        while((!$enviado)&&($intentos<5)&&($mail->ErrorInfo!="SMTP Error: Data not accepted")){
251           sleep(5);
252           //echo $mail->ErrorInfo;
253           $enviado = $mail->Send();
254           $intentos=$intentos+1;                               
255        }
256
257if ($mail->ErrorInfo=="SMTP Error: Data not accepted") { // soluciona un bug con attachements
258           $enviado=true;
259}
260
261//información final sobre el envío
262
263if($enviado)
264{
265echo "<div style='margin-left:15px;margin-right:15px'><center><font color='#333366'><br /><br /><h2 style='text-align:center; font-weight:bold; margin-bottom:.3em'><span style='text-decoration:underline'>#NOM_SITE_SPIP</span></h2><br /><h1 style='text-align:center; font-size:90%'>La referencia de<i><b><div style='padding-top:.6em;padding-bottom:.6em'>\"[(#TITRE|texte_script)]\"</div></b></i>ya se ha enviado a ". $HTTP_POST_VARS["destino"] ."</h1></font></center></div>";
266}
267else{
268echo "<div style='margin-left:15px;margin-right:15px'><center><font color='red'><br /><br /><h2 style='text-align:center; font-weight:bold; margin-bottom:.3em'><span style='text-decoration:underline'>#NOM_SITE_SPIP</span></h2><br /><h1 style='text-align:center; font-size:90%'>Lo sentimos<br />Ha habido un problema y no se ha podido enviar el correo :-(</h1></font></center></div>";
269}
270
271// Borro las direcciones de destino establecidas anteriormente
272        $mail->ClearAddresses();
273
274?>
275
276<div style="text-align:center; font-size:90%">
277<br />
278<input type="button"  class="spip_bouton" value="Cerrar" onclick="window.close();">
279</div>
280
281<?php
282}
283}
284?> 
285
286<div style="display:none">
287[(#FORMULAIRE_ADMIN)]
288</div>
289
290</body>
291</html>
292</BOUCLE_enviar_articulo>
Note: See TracBrowser for help on using the repository browser.