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