dolibarr  16.0.5
mails_ticket.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2016 Jonathan TISSEAU <jonathan.tisseau@86dev.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 
30 // Load translation files required by the page
31 $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors'));
32 
33 $action = GETPOST('action', 'aZ09');
34 $cancel = GETPOST('cancel', 'alpha');
35 
36 $usersignature = $user->signature;
37 // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
38 if ($action == 'test' || $action == 'send') {
39  $usersignature = dol_string_nohtmltag($usersignature);
40 }
41 
42 $substitutionarrayfortest = array(
43 '__LOGIN__' => $user->login,
44 '__ID__' => 'TESTIdRecord',
45 '__EMAIL__' => 'TESTEMail',
46 '__LASTNAME__' => 'TESTLastname',
47 '__FIRSTNAME__' => 'TESTFirstname',
48 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''),
49 //'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet
50 );
51 complete_substitutions_array($substitutionarrayfortest, $langs);
52 
53 // Security check
54 if (!$user->admin) {
56 }
57 
58 
59 /*
60  * Actions
61  */
62 
63 if ($action == 'update' && !$cancel) {
64  // Send mode parameters
65  dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity);
66  dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
67  dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
68  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
69  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET"), 'chaine', 0, '', $conf->entity);
70  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
71  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
72 
73  header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
74  exit;
75 }
76 
77 
78 // Actions to send emails
79 $id = 0;
80 $actiontypecode = ''; // Not an event for agenda
81 $triggersendname = ''; // Disable triggers
82 $paramname = 'id';
83 $mode = 'emailfortest';
84 $trackid = (($action == 'testhtml') ? "testhtml" : "test");
85 $sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket
86 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
87 
88 if ($action == 'presend' && GETPOST('trackid') == 'test') {
89  $action = 'test';
90 }
91 if ($action == 'presend' && GETPOST('trackid') == 'testhtml') {
92  $action = 'testhtml';
93 }
94 
95 
96 
97 
98 /*
99  * View
100  */
101 
102 $form = new Form($db);
103 
104 $linuxlike = 1;
105 if (preg_match('/^win/i', PHP_OS)) {
106  $linuxlike = 0;
107 }
108 if (preg_match('/^mac/i', PHP_OS)) {
109  $linuxlike = 0;
110 }
111 
112 if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) {
113  $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
114 }
115 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get('smtp_port');
116 if (!$port) {
117  $port = 25;
118 }
119 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get('SMTP');
120 if (!$server) {
121  $server = '127.0.0.1';
122 }
123 
124 
125 $wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
126 llxHeader('', $langs->trans("Setup"), $wikihelp);
127 
128 print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
129 
130 $head = email_admin_prepare_head();
131 
132 // List of sending methods
133 $listofmethods = array();
134 $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
135 $listofmethods['mail'] = 'PHP mail function';
136 //$listofmethods['simplemail']='Simplemail class';
137 $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
138 if (version_compare(phpversion(), '7.0', '>=')) {
139  $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
140 }
141 
142 
143 if ($action == 'edit') {
144  if ($conf->use_javascript_ajax) {
145  print "\n".'<script type="text/javascript">';
146  print 'jQuery(document).ready(function () {
147  function initfields()
148  {
149  if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
150  {
151  jQuery(".hideifdefault").hide();
152  }
153  else
154  {
155  jQuery(".hideifdefault").show();
156  }
157 
158  if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
159  {
160  jQuery(".drag").hide();
161  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
162  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
163  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
164  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
165  ';
166  if ($linuxlike) {
167  print '
168  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
169  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
170  jQuery("#smtp_server_mess").show();
171  jQuery("#smtp_port_mess").show();
172  ';
173  } else {
174  print '
175  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
176  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
177  jQuery("#smtp_server_mess").hide();
178  jQuery("#smtp_port_mess").hide();
179  ';
180  }
181  print '
182  }
183  if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
184  {
185  jQuery(".drag").show();
186  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.');
187  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
188  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.');
189  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
190  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
191  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
192  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
193  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
194  jQuery("#smtp_server_mess").hide();
195  jQuery("#smtp_port_mess").hide();
196  }
197  if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
198  {
199  jQuery(".drag").show();
200  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.');
201  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
202  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET.');
203  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
204  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
205  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
206  jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
207  jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
208  jQuery("#smtp_server_mess").hide();
209  jQuery("#smtp_port_mess").hide();
210  }
211  }
212  initfields();
213  jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
214  initfields();
215  });
216  jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
217  if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
218  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
219  });
220  jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
221  if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
222  jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
223  });
224  })';
225  print '</script>'."\n";
226  }
227 
228  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
229  print '<input type="hidden" name="token" value="'.newToken().'">';
230  print '<input type="hidden" name="action" value="update">';
231 
232  print dol_get_fiche_head($head, 'common_ticket', '', -1);
233 
234  print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
235  print "<br><br>\n";
236 
237 
238  clearstatcache();
239 
240  print '<table class="noborder centpercent">';
241  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
242 
243  // Method
244 
245  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
246 
247  // SuperAdministrator access only
248  if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
249  print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
250  } else {
251  $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET];
252  if (empty($text)) {
253  $text = $langs->trans("Undefined");
254  }
255  $htmltext = $langs->trans("ContactSuperAdminForChange");
256  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
257  print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.'">';
258  }
259  print '</td></tr>';
260 
261  // Host server
262 
263  print '<tr class="oddeven hideifdefault"><td>';
264  if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') {
265  print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
266  print '</td><td>';
267  print $langs->trans("SeeLocalSendMailSetup");
268  } else {
269  $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '');
270  $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
271  if ($linuxlike) {
272  print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
273  } else {
274  print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
275  }
276  print '</td><td>';
277  // SuperAdministrator access only
278  if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
279  print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">';
280  print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">';
281  print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
282  } else {
283  $text = !empty($mainserver) ? $mainserver : $smtpserver;
284  $htmltext = $langs->trans("ContactSuperAdminForChange");
285  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
286  print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.'">';
287  }
288  }
289  print '</td></tr>';
290 
291  // Port
292 
293  print '<tr class="oddeven hideifdefault"><td>';
294  if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') {
295  print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
296  print '</td><td>';
297  print $langs->trans("SeeLocalSendMailSetup");
298  } else {
299  $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '');
300  $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
301  if ($linuxlike) {
302  print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
303  } else {
304  print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
305  }
306  print '</td><td>';
307  // SuperAdministrator access only
308  if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
309  print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">';
310  print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">';
311  print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
312  } else {
313  $text = (!empty($mainport) ? $mainport : $smtpport);
314  $htmltext = $langs->trans("ContactSuperAdminForChange");
315  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
316  print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.'">';
317  }
318  }
319  print '</td></tr>';
320 
321  // ID
322  if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
323  $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : '');
324  print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
325  // SuperAdministrator access only
326  if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
327  print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">';
328  } else {
329  $htmltext = $langs->trans("ContactSuperAdminForChange");
330  print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1, 'superadmin');
331  print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.'">';
332  }
333  print '</td></tr>';
334  }
335 
336  // PW
337  if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
338  $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : '');
339  print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
340  // SuperAdministrator access only
341  if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
342  print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
343  } else {
344  $htmltext = $langs->trans("ContactSuperAdminForChange");
345  print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1, 'superadmin');
346  print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.'">';
347  }
348  print '</td></tr>';
349  }
350 
351  // TLS
352 
353  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
354  if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
355  if (function_exists('openssl_open')) {
356  print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
357  } else {
358  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
359  }
360  } else {
361  print yn(0).' ('.$langs->trans("NotSupported").')';
362  }
363  print '</td></tr>';
364 
365  // STARTTLS
366 
367  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
368  if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
369  if (function_exists('openssl_open')) {
370  print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
371  } else {
372  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
373  }
374  } else {
375  print yn(0).' ('.$langs->trans("NotSupported").')';
376  }
377  print '</td></tr>';
378 
379  print '</table>';
380 
381  print dol_get_fiche_end();
382 
383  print $form->buttonsSaveCancel();
384 
385  print '</form>';
386 } else {
387  print dol_get_fiche_head($head, 'common_ticket', '', -1);
388 
389  print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
390  print "<br><br>\n";
391 
392  print '<table class="noborder centpercent">';
393  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
394 
395  // Method
396  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
397  $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
398  if (empty($text)) {
399  $text = $langs->trans("Undefined").img_warning();
400  }
401  if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') {
402  print '<span class="opacitymedium">'.$text.'</span>';
403  } else {
404  print $text;
405  }
406  print '</td></tr>';
407 
408  if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
409  // Host server
410  if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) {
411  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
412  } else {
413  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'</td></tr>';
414  }
415 
416  // Port
417  if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail')) {
418  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
419  } else {
420  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'</td></tr>';
421  }
422 
423  // SMTPS ID
424  if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
425  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'</td></tr>';
426  }
427 
428  // SMTPS PW
429  if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
430  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'</td></tr>';
431  }
432 
433  // TLS
434  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
435  if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
436  if (function_exists('openssl_open')) {
437  print yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
438  } else {
439  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
440  }
441  } else {
442  print yn(0).' ('.$langs->trans("NotSupported").')';
443  }
444  print '</td></tr>';
445 
446  // STARTTLS
447  print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
448  if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
449  if (function_exists('openssl_open')) {
450  print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
451  } else {
452  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
453  }
454  } else {
455  print yn(0).' ('.$langs->trans("NotSupported").')';
456  }
457  print '</td></tr>';
458  }
459 
460  print '</table>';
461 
462  print dol_get_fiche_end();
463 
464 
465  if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
466  print '<br>';
467  /*
468  // Warning 1
469  if ($linuxlike)
470  {
471  $sendmailoption=ini_get('mail.force_extra_parameters');
472  if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
473  {
474  print info_admin($langs->trans("SendmailOptionNotComplete"));
475  }
476  }*/
477  // Warning 2
478  print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
479  }
480 
481 
482  // Buttons for actions
483 
484  print '<div class="tabsAction">';
485 
486  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
487 
488  if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
489  if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) {
490  if (function_exists('fsockopen') && $port && $server) {
491  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
492  }
493  } else {
494  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
495  }
496 
497  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
498 
499  if (!empty($conf->fckeditor->enabled)) {
500  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
501  }
502  }
503 
504  print '</div>';
505 
506 
507  if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
508  $text = $langs->trans("WarningPHPMail");
509  print info_admin($text);
510  }
511 
512  // Run the test to connect
513  if ($action == 'testconnect') {
514  print load_fiche_titre($langs->trans("DoTestServerAvailability"));
515 
516  include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
517  $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
518 
519  $result = $mail->check_server_port($server, $port);
520  if ($result) {
521  print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
522  } else {
523  $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
524 
525  if ($mail->error) {
526  $errormsg .= ' - '.$mail->error;
527  }
528 
529  setEventMessages($errormsg, null, 'errors');
530  }
531  print '<br>';
532  }
533 
534  // Show email send test form
535  if ($action == 'test' || $action == 'testhtml') {
536  print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
537  print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
538 
539  print dol_get_fiche_head('');
540 
541  // Cree l'objet formulaire mail
542  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
543  $formmail = new FormMail($db);
544  $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
545  $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
546  $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
547  $formmail->withfromreadonly = 0;
548  $formmail->withsubstit = 0;
549  $formmail->withfrom = 1;
550  $formmail->witherrorsto = 1;
551  $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
552  $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1);
553  $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1);
554  $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
555  $formmail->withtopicreadonly = 0;
556  $formmail->withfile = 2;
557  $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
558  $formmail->withbodyreadonly = 0;
559  $formmail->withcancel = 1;
560  $formmail->withdeliveryreceipt = 1;
561  $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
562  $formmail->ckeditortoolbar = 'dolibarr_mailings';
563  // Tableau des substitutions
564  $formmail->substit = $substitutionarrayfortest;
565  // Tableau des parametres complementaires du post
566  $formmail->param["action"] = "send";
567  $formmail->param["models"] = "body";
568  $formmail->param["mailid"] = 0;
569  $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
570 
571  // Init list of files
572  if (GETPOST("mode") == 'init') {
573  $formmail->clear_attached_files();
574  }
575 
576  print $formmail->get_form('addfile', 'removefile');
577 
578  print dol_get_fiche_end();
579  }
580 }
581 
582 // End of page
583 llxFooter();
584 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
CMailFile
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Definition: CMailFile.class.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:6694
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
email_admin_prepare_head
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: admin.lib.php:1991
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
complete_substitutions_array
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
Definition: functions.lib.php:7961