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