dolibarr  18.0.0-alpha
mails.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2020 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 // Load Dolibarr environment
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors"));
33 
34 $action = GETPOST('action', 'aZ09');
35 $cancel = GETPOST('cancel', 'aZ09');
36 
37 $trackid = GETPOST('trackid');
38 
39 if (!$user->admin) {
41 }
42 
43 $usersignature = $user->signature;
44 // For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html.
45 if ($action == 'test' || ($action == 'send' && $trackid = 'test')) {
46  $usersignature = dol_string_nohtmltag($usersignature, 2);
47 }
48 
49 $substitutionarrayfortest = array(
50  '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
51  '__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefinedtag&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-undefinedtag", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0" />',
52  '__USER_LOGIN__' => $user->login,
53  '__USER_EMAIL__' => $user->email,
54  '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
55  '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
56  '__ID__' => 'RecipientIdRecord',
57  //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
58  '__LOGIN__' => $user->login,
59  '__LASTNAME__' => 'RecipientLastname',
60  '__FIRSTNAME__' => 'RecipientFirstname',
61  '__ADDRESS__'=> 'RecipientAddress',
62  '__ZIP__'=> 'RecipientZip',
63  '__TOWN_'=> 'RecipientTown',
64  '__COUNTRY__'=> 'RecipientCountry'
65 );
66 complete_substitutions_array($substitutionarrayfortest, $langs);
67 
68 
69 
70 /*
71  * Actions
72  */
73 
74 if ($action == 'update' && !$cancel) {
75  if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) {
76  $error++;
77  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors');
78  $action = 'edit';
79  }
80  if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) {
81  $error++;
82  setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors');
83  $action = 'edit';
84  }
85 
86  if (!$error) {
87  dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity);
88  dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
89  dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity);
90  // Send mode parameters
91  dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity);
92  dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
93  dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
94  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
95  if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
96  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
97  }
98  if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
99  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
100  }
101  if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
102  dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
103  }
104  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
105  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
106  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
107 
108  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity);
109  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
110  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
111  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
112  // Content parameters
113  dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
114  dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
115  dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
116  dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
117 
118  header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
119  exit;
120  }
121 }
122 
123 if ($action == 'disablephpmailwarning' && !$cancel) {
124  dolibarr_set_const($db, 'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1, 'chaine', 1, 0, $conf->entity);
125 
126  setEventMessages($langs->trans("WarningDisabled"), null, 'mesgs');
127 }
128 
129 // Actions to send emails
130 $id = 0;
131 $actiontypecode = ''; // Not an event for agenda
132 $triggersendname = ''; // Disable triggers
133 $paramname = 'id';
134 $mode = 'emailfortest';
135 $trackid = ($action == 'send' ? GETPOST('trackid', 'aZ09') : $action);
136 $sendcontext = '';
137 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
138 
139 if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
140  $action = 'test';
141 }
142 if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
143  $action = 'testhtml';
144 }
145 
146 
147 
148 /*
149  * View
150  */
151 
152 $form = new Form($db);
153 
154 $linuxlike = 1;
155 if (preg_match('/^win/i', PHP_OS)) {
156  $linuxlike = 0;
157 }
158 if (preg_match('/^mac/i', PHP_OS)) {
159  $linuxlike = 0;
160 }
161 
162 if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
163  $conf->global->MAIN_MAIL_SENDMODE = 'mail';
164 }
165 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');
166 if (!$port) {
167  $port = 25;
168 }
169 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP');
170 if (!$server) {
171  $server = '127.0.0.1';
172 }
173 
174 
175 $wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
176 llxHeader('', $langs->trans("Setup"), $wikihelp);
177 
178 print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
179 
180 $head = email_admin_prepare_head();
181 
182 // List of sending methods
183 $listofmethods = array();
184 $listofmethods['mail'] = 'PHP mail function';
185 $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
186 if (version_compare(phpversion(), '7.0', '>=')) {
187  $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
188 }
189 
190 // List of oauth services
191 $oauthservices = array();
192 
193 foreach ($conf->global as $key => $val) {
194  if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
195  $key = preg_replace('/^OAUTH_/', '', $key);
196  $key = preg_replace('/_ID$/', '', $key);
197  if (preg_match('/^.*-/', $key)) {
198  $name = preg_replace('/^.*-/', '', $key);
199  } else {
200  $name = $langs->trans("NoName");
201  }
202  $provider = preg_replace('/-.*$/', '', $key);
203  $provider = ucfirst(strtolower($provider));
204 
205  $oauthservices[$key] = $name." (".$provider.")";
206  }
207 }
208 
209 if ($action == 'edit') {
210  if ($conf->use_javascript_ajax) {
211  print "\n".'<script type="text/javascript">';
212  print 'jQuery(document).ready(function () {
213  function initfields()
214  {
215  if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
216  {
217  console.log("I choose php mail mode");
218  jQuery(".drag").hide();
219  jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
220  jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
221  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
222  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
223  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
224  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
225  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
226  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
227  jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
228  jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
229  jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
230  jQuery(".smtp_method").hide();
231  jQuery(".dkim").hide();
232  jQuery(".smtp_auth_method").hide();
233  ';
234  if ($linuxlike) {
235  print '
236  jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
237  jQuery("#MAIN_MAIL_SMTP_PORT").hide();
238  jQuery("#smtp_server_mess").show();
239  jQuery("#smtp_port_mess").show();';
240  } else {
241  print '
242  jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
243  jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
244  jQuery("#smtp_server_mess").hide();
245  jQuery("#smtp_port_mess").hide();';
246  }
247  print '
248  }
249  if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
250  {
251  console.log("I choose smtps mode");
252  jQuery(".drag").show();
253  jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.');
254  jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
255  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.');
256  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
257  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.');
258  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
259  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
260  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
261  jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
262  jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
263  jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
264  jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
265  jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
266  jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
267  jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
268  jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
269  jQuery("#MAIN_MAIL_SMTP_SERVER").show();
270  jQuery("#MAIN_MAIL_SMTP_PORT").show();
271  jQuery("#smtp_server_mess").hide();
272  jQuery("#smtp_port_mess").hide();
273  jQuery(".smtp_method").show();
274  jQuery(".dkim").hide();
275  jQuery(".smtp_auth_method").show();
276  }
277  if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
278  {
279  console.log("I choose swiftmailer mode");
280  jQuery(".drag").show();
281  jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.');
282  jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
283  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.');
284  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
285  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.');
286  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
287  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.');
288  jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
289  jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
290  jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
291  jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
292  jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
293  jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
294  jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
295  jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
296  jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
297  jQuery("#MAIN_MAIL_SMTP_SERVER").show();
298  jQuery("#MAIN_MAIL_SMTP_PORT").show();
299  jQuery("#smtp_server_mess").hide();
300  jQuery("#smtp_port_mess").hide();
301  jQuery(".smtp_method").show();
302  jQuery(".dkim").show();
303  jQuery(".smtp_auth_method").show();
304  }
305  }
306  function change_smtp_auth_method() {
307  console.log(jQuery("#radio_pw").prop("checked"));
308  if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
309  jQuery(".smtp_oauth_service").show();
310  jQuery(".smtp_pw").hide();
311  } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
312  jQuery(".smtp_oauth_service").show();
313  jQuery(".smtp_pw").hide();
314  } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
315  jQuery(".smtp_oauth_service").hide();
316  jQuery(".smtp_pw").hide();
317  } else {
318  jQuery(".smtp_oauth_service").hide();
319  jQuery(".smtp_pw").show();
320  }
321  }
322  initfields();
323  change_smtp_auth_method();
324  jQuery("#MAIN_MAIL_SENDMODE").change(function() {
325  initfields();
326  change_smtp_auth_method();
327  });
328  jQuery("#radio_pw, #radio_oauth").change(function() {
329  change_smtp_auth_method();
330  });
331  jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
332  if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
333  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
334  else
335  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
336  });
337  jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
338  if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
339  jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
340  else
341  jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
342  });
343  })';
344  print '</script>'."\n";
345  }
346 
347  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
348  print '<input type="hidden" name="token" value="'.newToken().'">';
349  print '<input type="hidden" name="action" value="update">';
350 
351  print dol_get_fiche_head($head, 'common', '', -1);
352 
353  print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
354  print "<br><br>\n";
355 
356 
357  clearstatcache();
358 
359  print '<table class="noborder centpercent">';
360  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
361 
362  // Disable
363  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>';
364  print $form->selectyesno('MAIN_DISABLE_ALL_MAILS', getDolGlobalString('MAIN_DISABLE_ALL_MAILS'), 1);
365  print '</td></tr>';
366 
367  // Force e-mail recipient
368  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>';
369  print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO : '').'" />';
370  print '</td></tr>';
371 
372  print '</table>';
373 
374  print '<br>';
375 
376  print '<table class="noborder centpercent">';
377  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
378 
379  // Method
380  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
381 
382  // SuperAdministrator access only
383  if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
384  print $form->selectarray('MAIN_MAIL_SENDMODE', $listofmethods, getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'));
385  } else {
386  $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
387  if (empty($text)) {
388  $text = $langs->trans("Undefined");
389  }
390  $htmltext = $langs->trans("ContactSuperAdminForChange");
391  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
392  print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail').'">';
393  }
394  print '</td></tr>';
395 
396  // Host server
397  print '<tr class="oddeven">';
398  if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
399  print '<td>';
400  print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
401  print '</td><td>';
402  print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
403  print '</td>';
404  } else {
405  print '<td>';
406  $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '');
407  $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
408  if ($linuxlike) {
409  print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
410  } else {
411  print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
412  }
413  print '</td><td>';
414  // SuperAdministrator access only
415  if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
416  print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'" autocomplete="off">';
417  print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">';
418  print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
419  print ' <span class="opacitymedium smtp_method">'.$langs->trans("SeeLinkToOnlineDocumentation").'</span>';
420  } else {
421  $text = !empty($mainserver) ? $mainserver : $smtpserver;
422  $htmltext = $langs->trans("ContactSuperAdminForChange");
423  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
424  print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'">';
425  }
426  print '</td>';
427  }
428  print '</tr>';
429 
430  // Port
431  print '<tr class="oddeven"><td>';
432  if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
433  print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
434  print '</td><td>';
435  print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
436  } else {
437  $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
438  $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
439  if ($linuxlike) {
440  print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
441  } else {
442  print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
443  }
444  print '</td><td>';
445  // SuperAdministrator access only
446  if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
447  print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">';
448  print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">';
449  print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
450  } else {
451  $text = (!empty($mainport) ? $mainport : $smtpport);
452  $htmltext = $langs->trans("ContactSuperAdminForChange");
453  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
454  print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.'">';
455  }
456  }
457  print '</td></tr>';
458 
459  // Auth mode
460  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
461  print '<tr class="oddeven smtp_auth_method"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
462  if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
463  // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case)
464  print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
465  print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
466  print '&nbsp; &nbsp; &nbsp;';
467  print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') == 'XOAUTH2' ? ' checked' : '').'> ';
468  print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
469  } else {
470  $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
471  $htmltext = $langs->trans("ContactSuperAdminForChange");
472  print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
473  print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.'">';
474  }
475  print '</td></tr>';
476  }
477 
478  // ID
479  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
480  $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
481  print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
482  // SuperAdministrator access only
483  if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
484  print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">';
485  } else {
486  $htmltext = $langs->trans("ContactSuperAdminForChange");
487  print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1, 'superadmin');
488  print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.'">';
489  }
490  print '</td></tr>';
491  }
492 
493 
494  // PW
495  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
496  $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
497  print '<tr class="drag drop oddeven smtp_pw"><td>';
498  print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
499  print '</td><td>';
500  // SuperAdministrator access only
501  if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
502  print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.'" autocomplete="off">';
503  } else {
504  $htmltext = $langs->trans("ContactSuperAdminForChange");
505  print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1, 'superadmin');
506  print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.'">';
507  }
508  print '</td></tr>';
509  }
510 
511  // OAUTH service provider
512  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
513  print '<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
514 
515  // SuperAdministrator access only
516  if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
517  print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
518  } else {
519  $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
520  if (empty($text)) {
521  $text = $langs->trans("Undefined");
522  }
523  $htmltext = $langs->trans("ContactSuperAdminForChange");
524  print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
525  print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE.'">';
526  }
527  print '</td></tr>';
528  }
529  // TLS
530  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
531  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
532  if (function_exists('openssl_open')) {
533  print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
534  } else {
535  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
536  }
537  } else {
538  print yn(0).' ('.$langs->trans("NotSupported").')';
539  }
540  print '</td></tr>';
541 
542  // STARTTLS
543  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
544  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
545  if (function_exists('openssl_open')) {
546  print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
547  } else {
548  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
549  }
550  } else {
551  print yn(0).' ('.$langs->trans("NotSupported").')';
552  }
553  print '</td></tr>';
554 
555  // SMTP_ALLOW_SELF_SIGNED
556  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
557  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
558  if (function_exists('openssl_open')) {
559  print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
560  } else {
561  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
562  }
563  } else {
564  print yn(0).' ('.$langs->trans("NotSupported").')';
565  }
566  print '</td></tr>';
567 
568  // DKIM
569  print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
570  if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer')))) {
571  if (function_exists('openssl_open')) {
572  print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
573  } else {
574  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
575  }
576  } else {
577  print yn(0).' ('.$langs->trans("NotSupported").')';
578  }
579  print '</td></tr>';
580 
581  // DKIM Domain
582  print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
583  print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN : '');
584  print '"></td></tr>';
585 
586  // DKIM Selector
587  print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
588  print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR : '');
589  print '"></td></tr>';
590 
591  // DKIM PRIVATE KEY
592  print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
593  print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY : '').'</textarea>';
594  print '</td></tr>';
595 
596  print '</table>';
597 
598  print '<br>';
599 
600  print '<table class="noborder centpercent">';
601  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
602 
603  // From
604  $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
605  print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.'</td>';
606  print '<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? $conf->global->MAIN_MAIL_EMAIL_FROM : '');
607  print '"></td></tr>';
608 
609  // Default from type
610  $liste = array();
611  $liste['user'] = $langs->trans('UserEmail');
612  $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
613 
614  print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td><td>';
615  print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
616  print '</td></tr>';
617 
618  // From
619  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
620  print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : '');
621  print '"></td></tr>';
622 
623  // Autocopy to
624  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
625  print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO : '');
626  print '"></td></tr>';
627 
628  // Add user to select destinaries list
629  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>';
630  print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
631  print '</td></tr>';
632 
633  print '</table>';
634 
635  print dol_get_fiche_end();
636 
637  print $form->buttonsSaveCancel();
638 
639  print '</form>';
640 } else {
641  print dol_get_fiche_head($head, 'common', '', -1);
642 
643  print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
644  print "<br><br>\n";
645 
646  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
647  print '<table class="noborder centpercent">';
648  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
649 
650  // Disable
651  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
652  if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
653  print img_warning($langs->trans("Disabled"));
654  }
655  print '</td></tr>';
656 
657  if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
658  // Force e-mail recipient
659  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
660  if (!empty(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
661  if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
662  print img_warning($langs->trans("ErrorBadEMail"));
663  } else {
664  print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
665  }
666  }
667  print '</td></tr>';
668  }
669 
670  print '</table>';
671  print '</div>';
672 
673  if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
674  print '<br>';
675 
676  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
677  print '<table class="noborder centpercent">';
678  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
679 
680  // Method
681  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
682  $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail')];
683  if (empty($text)) {
684  $text = $langs->trans("Undefined").img_warning();
685  }
686  print $text;
687 
688  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
689  $textwarning = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
690  print $form->textwithpicto('', $textwarning, 1, 'warning');
691  }
692 
693  print '</td></tr>';
694 
695  // Host server
696  if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
697  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
698  } else {
699  print '<tr class="oddeven"><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) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>';
700  }
701 
702 
703  // Port
704  if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
705  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
706  } else {
707  print '<tr class="oddeven"><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) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>';
708  }
709 
710  // AUTH method
711  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
712  $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
713  $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
714  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
715  }
716 
717  // SMTPS ID
718  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
719  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>';
720  }
721 
722  // SMTPS PW
723  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
724  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>';
725  }
726 
727  // SMTPS oauth service
728  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
729  $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
730  if (empty($text)) {
731  $text = $langs->trans("Undefined").img_warning();
732  }
733  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
734  }
735 
736  // TLS
737  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
738  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
739  if (function_exists('openssl_open')) {
740  print yn($conf->global->MAIN_MAIL_EMAIL_TLS);
741  } else {
742  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
743  }
744  } else {
745  print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
746  }
747  print '</td></tr>';
748 
749  // STARTTLS
750  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
751  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
752  if (function_exists('openssl_open')) {
753  print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
754  } else {
755  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
756  }
757  } else {
758  print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
759  }
760  print '</td></tr>';
761 
762  // SMTP_ALLOW_SELF_SIGNED
763  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
764  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
765  if (function_exists('openssl_open')) {
766  print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
767  } else {
768  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
769  }
770  } else {
771  print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
772  }
773  print '</td></tr>';
774 
775 
776  if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') {
777  // DKIM
778  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
779  if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer'))) {
780  if (function_exists('openssl_open')) {
781  print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_DKIM_ENABLED'));
782  } else {
783  print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
784  }
785  } else {
786  print yn(0).' ('.$langs->trans("NotSupported").')';
787  }
788  print '</td></tr>';
789 
790  // Domain
791  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
792  print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_DOMAIN');
793  print '</td></tr>';
794 
795  // Selector
796  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
797  print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_SELECTOR');
798  print '</td></tr>';
799 
800  // PRIVATE KEY
801  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
802  print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
803  print '</td></tr>';
804  }
805 
806  print '</table>';
807  print '</div>';
808 
809  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
810  $messagetoshow = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
811  $messagetoshow .= ' '.$langs->trans("WarningPHPMailDbis", '{s1}', '{s2}');
812  $linktosetvar1 = '<a href="'.$_SERVER["PHP_SELF"].'?action=disablephpmailwarning&token='.newToken().'">';
813  $linktosetvar2 = '</a>';
814  $messagetoshow = str_replace('{s1}', $linktosetvar1, $messagetoshow);
815  $messagetoshow = str_replace('{s2}', $linktosetvar2, $messagetoshow);
816  print info_admin($messagetoshow, 0, 0, 'warning');
817  }
818 
819  print '<br>';
820 
821  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
822  print '<table class="noborder centpercent">';
823  print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
824 
825  // From
826  $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
827  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.'</td>';
828  print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
829  if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
830  print img_warning($langs->trans("Mandatory"));
831  } elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
832  print img_warning($langs->trans("ErrorBadEMail"));
833  }
834  print '</td></tr>';
835 
836  // Default from type
837  $liste = array();
838  $liste['user'] = $langs->trans('UserEmail');
839  $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
840  $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
841  $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
842  $resql = $db->query($sql);
843  if ($resql) {
844  $num = $db->num_rows($resql);
845  $i = 0;
846  while ($i < $num) {
847  $obj = $db->fetch_object($resql);
848  if ($obj) {
849  $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
850  }
851  $i++;
852  }
853  } else {
854  dol_print_error($db);
855  }
856 
857  print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
858  print '<td>';
859  if (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'robot') {
860  print $langs->trans('RobotEmail');
861  } elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'user') {
862  print $langs->trans('UserEmail');
863  } elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') {
864  print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
865  } else {
866  $id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'));
867  if ($id > 0) {
868  include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
869  $emailsenderprofile = new EmailSenderProfile($db);
870  $emailsenderprofile->fetch($id);
871  print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>');
872  }
873  }
874  print '</td></tr>';
875 
876  // Errors To
877  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
878  print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
879  if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
880  print img_warning($langs->trans("ErrorBadEMail"));
881  }
882  print '</td></tr>';
883 
884  // Autocopy to
885  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
886  print '<td>';
887  if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
888  $listofemail = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
889  $i = 0;
890  foreach ($listofemail as $key => $val) {
891  if ($i) {
892  print ', ';
893  }
894  $val = trim($val);
895  print $val;
896  if (!isValidEmail($val, 0, 1)) {
897  print img_warning($langs->trans("ErrorBadEMail", $val));
898  }
899  $i++;
900  }
901  } else {
902  print '&nbsp;';
903  }
904  print '</td></tr>';
905 
906  //Add user to select destinaries list
907  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>'.yn(!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)).'</td></tr>';
908 
909  print '</table>';
910  print '</div>';
911  }
912 
913  print dol_get_fiche_end();
914 
915 
916  // Actions button
917  print '<div class="tabsAction">';
918 
919  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
920 
921  if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
922  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') != 'mail' || !$linuxlike) {
923  if (function_exists('fsockopen') && $port && $server) {
924  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
925  }
926  } else {
927  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
928  }
929 
930  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>';
931 
932  if (isModEnabled('fckeditor')) {
933  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>';
934  }
935  }
936 
937  print '</div>';
938 
939 
940  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
941  /*
942  // Warning 1
943  if ($linuxlike)
944  {
945  $sendmailoption=ini_get('mail.force_extra_parameters');
946  if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
947  {
948  print info_admin($langs->trans("SendmailOptionNotComplete"));
949  }
950  }*/
951  // Warning 2
952  print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
953  }
954 
955  if (!in_array($action, array('testconnect', 'test', 'testhtml'))) {
956  $text = '';
957  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
958  //$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
959  }
960 
961  if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
962  if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
963  // List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com'
964  $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
965  } else {
966  // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'.
967  if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
968  // List of IP show as record to add in SPF if we use the mail method
969  $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
970  }
971  }
972  } else {
973  if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
974  // List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]'
975  // TODO Add a key to allow to show the IP/name of server detected dynamically
976  $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
977  }
978  if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server.
979  // List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com'
980  $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
981  }
982  }
983  $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL');
984  $dnsinfo = false;
985  if (!empty($companyemail) && function_exists('dns_get_record')) {
986  $arrayofemailparts = explode('@', $companyemail);
987  if (count($arrayofemailparts) == 2) {
988  $domain = $arrayofemailparts[1];
989  $dnsinfo = dns_get_record($domain, DNS_TXT);
990  }
991  }
992  if (!empty($dnsinfo) && is_array($dnsinfo)) {
993  foreach ($dnsinfo as $info) {
994  if (strpos($info['txt'], 'v=spf') !== false) {
995  $text .= ($text ? '<br><br>' : '').$langs->trans("ActualMailSPFRecordFound", $companyemail, $info['txt']);
996  }
997  }
998  }
999  if ($text) {
1000  print info_admin($text);
1001  }
1002  }
1003 
1004  // Run the test to connect
1005  if ($action == 'testconnect') {
1006  print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1007  print load_fiche_titre($langs->trans("DoTestServerAvailability"));
1008 
1009  include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
1010  $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
1011  $result = $mail->check_server_port($server, $port);
1012  if ($result) {
1013  print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
1014  } else {
1015  $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
1016 
1017  if ($mail->error) {
1018  $errormsg .= ' - '.$mail->error;
1019  }
1020 
1021  setEventMessages($errormsg, null, 'errors');
1022  }
1023  print '<br>';
1024  }
1025 
1026  // Show email send test form
1027  if ($action == 'test' || $action == 'testhtml') {
1028  print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1029  print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
1030 
1031  print dol_get_fiche_head('');
1032 
1033  // Cree l'objet formulaire mail
1034  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1035  $formmail = new FormMail($db);
1036  $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
1037  $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1038  $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1039  $formmail->fromid = $user->id;
1040  $formmail->fromalsorobot = 1;
1041  $formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
1042  $formmail->withfromreadonly = 1;
1043  $formmail->withsubstit = 1;
1044  $formmail->withfrom = 1;
1045  $formmail->witherrorsto = 1;
1046  $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
1047  $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
1048  $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
1049  $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
1050  $formmail->withtopicreadonly = 0;
1051  $formmail->withfile = 2;
1052  $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
1053  $formmail->withbodyreadonly = 0;
1054  $formmail->withcancel = 1;
1055  $formmail->withdeliveryreceipt = 1;
1056  $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
1057  $formmail->ckeditortoolbar = 'dolibarr_mailings';
1058  // Tableau des substitutions
1059  $formmail->substit = $substitutionarrayfortest;
1060  // Tableau des parametres complementaires du post
1061  $formmail->param["action"] = "send";
1062  $formmail->param["models"] = "body";
1063  $formmail->param["mailid"] = 0;
1064  $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
1065 
1066  // Init list of files
1067  if (GETPOST("mode", "aZ09") == 'init') {
1068  $formmail->clear_attached_files();
1069  }
1070 
1071  print $formmail->get_form('addfile', 'removefile');
1072 
1073  print dol_get_fiche_end();
1074 
1075  // References
1076  print '<span class="opacitymedium">'.$langs->trans("EMailsWillHaveMessageID").': ';
1077  print dol_escape_htmltag('<timestamp.*@'.dol_getprefix('email').'>');
1078  print '</span>';
1079  }
1080 }
1081 
1082 // End of page
1083 llxFooter();
1084 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6743
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1534
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
$sql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:745
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5400
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:551
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5031
img_help
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Definition: functions.lib.php:4668
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4708
$wikihelp
if(GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) if(GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:90
CMailFile
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Definition: CMailFile.class.php:41
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
dol_hash
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
Definition: security.lib.php:218
isValidEmail
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
Definition: functions.lib.php:3834
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:6965
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:4987
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11438
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2104
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:166
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Definition: functions.lib.php:1906
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:101
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:633
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:451
email_admin_prepare_head
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: admin.lib.php:2029
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2982
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8552
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1131
EmailSenderProfile
Class for EmailSenderProfile.
Definition: emailsenderprofile.class.php:37
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:115
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:8376