dolibarr 24.0.0-beta
mails_ticket.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2016 Jonathan TISSEAU <jonathan.tisseau@86dev.fr>
6 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32
41// Load translation files required by the page
42$langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors'));
43
44$action = GETPOST('action', 'aZ09');
45$cancel = GETPOST('cancel', 'alpha');
46
47$usersignature = $user->signature;
48// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
49if ($action == 'test' || $action == 'send') {
50 $usersignature = dol_string_nohtmltag($usersignature, 2);
51}
52
53$substitutionarrayfortest = array(
54 '__ID__' => 'TESTIdRecord',
55 '__USER_LOGIN__' => $user->login,
56 '__USER_EMAIL__' => $user->email,
57 '__USER_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
58 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
59 '__LASTNAME__' => 'RecipientLastname',
60 '__FIRSTNAME__' => 'RecipientFirstname',
61 '__ADDRESS__' => 'RecipientAddress',
62 '__ZIP__' => 'RecipientZip',
63 '__TOWN_' => 'RecipientTown',
64 '__COUNTRY__' => 'RecipientCountry',
65 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
66);
67complete_substitutions_array($substitutionarrayfortest, $langs);
68
69// List of sending methods
70$listofmethods = array();
71$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
72$listofmethods['mail'] = 'PHP mail function';
73//$listofmethods['simplemail']='Simplemail class';
74$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
75if (version_compare(phpversion(), '7.0', '>=')) {
76 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
77}
78
79// Security check
80if (!$user->admin) {
82}
83
84
85/*
86 * Actions
87 */
88
89if ($action == 'update' && !$cancel) {
90 // Send mode parameters
91 dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity);
92 dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
93 dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
94 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
95 if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_TICKET")) {
96 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET", 'password'), 'chaine', 0, '', $conf->entity);
97 }
98 if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
99 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
100 }
101 if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
102 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
103 }
104 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
105 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
106 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET"), 'chaine', 0, '', $conf->entity);
107
108 include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
109
110 header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
111 exit;
112}
113
114
115// Actions to send emails
116$id = 0;
117$actiontypecode = ''; // Not an event for agenda
118$triggersendname = ''; // Disable triggers
119$paramname = 'id';
120$mode = 'emailfortest';
121$trackid = (($action == 'testhtml') ? "testhtml" : "test");
122$sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket
123include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
124
125if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
126 $action = 'test';
127}
128if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
129 $action = 'testhtml';
130}
131
132
133
134
135/*
136 * View
137 */
138
139$form = new Form($db);
140
141$linuxlike = 1;
142if (preg_match('/^win/i', PHP_OS)) {
143 $linuxlike = 0;
144}
145if (preg_match('/^mac/i', PHP_OS)) {
146 $linuxlike = 0;
147}
148
149if (!getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')) {
150 $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
151}
152$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', (int) ini_get('smtp_port'));
153if (!$port) {
154 $port = 25;
155}
156$server = getDolGlobalString('MAIN_MAIL_SMTP_SERVER_TICKET', ini_get('SMTP'));
157if (!$server) {
158 $server = '127.0.0.1';
159}
160
161
162$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
163llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-mails_ticket');
164
165print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
166
168
169// List of oauth services
170$oauthservices = array();
171
172foreach ($conf->global as $key => $val) {
173 if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
174 $key = preg_replace('/^OAUTH_/', '', $key);
175 $key = preg_replace('/_ID$/', '', $key);
176 if (preg_match('/^.*-/', $key)) {
177 $name = preg_replace('/^.*-/', '', $key);
178 } else {
179 $name = $langs->trans("NoName");
180 }
181 $provider = preg_replace('/-.*$/', '', $key);
182 $provider = ucfirst(strtolower($provider));
183
184 $oauthservices[$key] = $name." (".$provider.")";
185 }
186}
187
188
189if ($action == 'edit') {
190 if ($conf->use_javascript_ajax) {
191 print "\n".'<script type="text/javascript">';
192 print 'jQuery(document).ready(function () {
193 function initfields()
194 {
195 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
196 {
197 jQuery(".hideifdefault").hide();
198 }
199 else
200 {
201 jQuery(".hideifdefault").show();
202 }
203
204 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
205 {
206 console.log("I choose php mail mode");
207 jQuery(".drag").hide();
208 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
209 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
210 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
211 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
212 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(0);
213 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").prop("disabled", true);
214 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
215 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
216 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
217 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
218 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
219 jQuery(".smtp_method").hide();
220 jQuery(".dkim").hide();
221 jQuery(".smtp_auth_method").hide();
222 ';
223 if ($linuxlike) {
224 print '
225 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
226 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
227 jQuery("#smtp_server_mess").show();
228 jQuery("#smtp_port_mess").show();
229 ';
230 } else {
231 print '
232 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
233 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
234 jQuery("#smtp_server_mess").hide();
235 jQuery("#smtp_port_mess").hide();
236 ';
237 }
238 print '
239 }
240 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
241 {
242 console.log("I choose smtps mail mode");
243 jQuery(".drag").show();
244 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
245 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET').');
247 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').');
249 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
255 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
256 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
257 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
258 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
260 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
261 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
262 jQuery("#smtp_server_mess").hide();
263 jQuery("#smtp_port_mess").hide();
264 jQuery(".smtp_method").show();
265 jQuery(".dkim").hide();
266 jQuery(".smtp_auth_method").show();
267 }
268 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
269 {
270 console.log("I choose swiftmailer mail mode");
271 jQuery(".drag").show();
272 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
273 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
274 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET').');
275 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').');
277 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
283 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
284 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
285 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
286 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
288 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
289 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
290 jQuery("#smtp_server_mess").hide();
291 jQuery("#smtp_port_mess").hide();
292 jQuery(".smtp_method").show();
293 jQuery(".dkim").show();
294 jQuery(".smtp_auth_method").show();
295 }
296 }
297 function change_smtp_auth_method() {
298 console.log("Call smtp auth method "+jQuery("#MAIN_MAIL_SENDMODE_TICKET").val());
299 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\') {
300 if (jQuery("#radio_oauth").prop("checked")) {
301 jQuery(".smtp_pw").hide();
302 jQuery(".smtp_oauth_service").show();
303 } else {
304 jQuery(".smtp_pw").show();
305 jQuery(".smtp_oauth_service").hide();
306 }
307 } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\') {
308 if (jQuery("#radio_oauth").prop("checked")) {
309 jQuery(".smtp_pw").hide();
310 jQuery(".smtp_oauth_service").show();
311 } else {
312 jQuery(".smtp_pw").show();
313 jQuery(".smtp_oauth_service").hide();
314 }
315 } else {
316 jQuery(".smtp_pw").hide();
317 jQuery(".smtp_oauth_service").hide();
318 }
319 }
320
321 initfields();
322 change_smtp_auth_method();
323
324 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
325 initfields();
326 change_smtp_auth_method();
327 });
328 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
329 change_smtp_auth_method();
330 });
331 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
332 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
333 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
334 });
335 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
336 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
337 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
338 });
339 })';
340 print '</script>'."\n";
341 }
342
343 print '<form method="post" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
344 print '<input type="hidden" name="token" value="'.newToken().'">';
345 print '<input type="hidden" name="action" value="update">';
346
347 print dol_get_fiche_head($head, 'common_ticket', '', -1);
348
349 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
350 print "<br><br>\n";
351
352
353 clearstatcache();
354
355 print '<table class="noborder centpercent">';
356 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
357
358 // Method
359
360 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
361
362 // SuperAdministrator access only
363 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
364 print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'));
365 } else {
366 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
367 if (empty($text)) {
368 $text = $langs->trans("Undefined");
369 }
370 $htmltext = $langs->trans("ContactSuperAdminForChange");
371 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
372 print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="' . getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET').'">';
373 }
374 print '</td></tr>';
375
376 // Host server
377
378 print '<tr class="oddeven hideifdefault">';
379 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail') {
380 print '<td>';
381 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
382 print '</td><td>';
383 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
384 print '</td>';
385 } else {
386 print '<td>';
387 $mainserver = getDolGlobalString('MAIN_MAIL_SMTP_SERVER_TICKET');
388 $smtpserver = ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined");
389 if ($linuxlike) {
390 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
391 } else {
392 print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
393 }
394 print '</td><td>';
395 // SuperAdministrator access only
396 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
397 print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">';
398 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">';
399 print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
400 print ' <span class="opacitymedium smtp_method">' . $langs->trans("SeeLinkToOnlineDocumentation") . '</span>';
401 } else {
402 $text = !empty($mainserver) ? $mainserver : $smtpserver;
403 $htmltext = $langs->trans("ContactSuperAdminForChange");
404 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
405 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.'">';
406 }
407 print '</td>';
408 }
409 print '</tr>';
410
411 // Port
412
413 print '<tr class="oddeven hideifdefault hideonmodemail"><td>';
414 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail') {
415 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
416 print '</td><td>';
417 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
418 } else {
419 $mainport = getDolGlobalString('MAIN_MAIL_SMTP_PORT_TICKET');
420 $smtpport = ini_get('smtp_port') ? ini_get('smtp_port') : $langs->transnoentities("Undefined");
421 if ($linuxlike) {
422 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
423 } else {
424 print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
425 }
426 print '</td><td>';
427 // SuperAdministrator access only
428 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
429 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">';
430 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">';
431 print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
432 } else {
433 $text = (!empty($mainport) ? $mainport : $smtpport);
434 $htmltext = $langs->trans("ContactSuperAdminForChange");
435 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
436 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.'">';
437 }
438 }
439 print '</td></tr>';
440
441 // AUTH method
442 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
443 print '<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
444 $vartosmtpstype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET';
445 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
446 // 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)
447 print '<input type="radio" id="radio_pw" name="'.$vartosmtpstype.'" value="LOGIN"'.(getDolGlobalString($vartosmtpstype, 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
448 print '<label for="radio_pw" >'.$langs->trans("UseAUTHLOGIN").'</label>';
449 print '<br>';
450 print '<input type="radio" id="radio_plain" name="'.$vartosmtpstype.'" value="PLAIN"'.(getDolGlobalString($vartosmtpstype, 'PLAIN') == 'PLAIN' ? ' checked' : '').'> ';
451 print '<label for="radio_plain" >'.$langs->trans("UseAUTHPLAIN").'</label>';
452 print '<br>';
453 print '<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.'" value="XOAUTH2"'.(getDolGlobalString($vartosmtpstype) == 'XOAUTH2' ? ' checked' : '').(isModEnabled('oauth') ? '' : ' disabled').'> ';
454 print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
455 if (!isModEnabled('oauth')) {
456 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword=oauth">'.$langs->trans("EnableModuleX", "OAuth").'</a>';
457 } else {
458 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/oauth.php">'.$langs->trans("SetupModuleX", " OAuth").'</a>';
459 }
460 } else {
461 $value = getDolGlobalString($vartosmtpstype, 'LOGIN');
462 $htmltext = $langs->trans("ContactSuperAdminForChange");
463 print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
464 print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.'">';
465 }
466 print '</td></tr>';
467 }
468
469 // ID
470 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
471 $mainstmpid = getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET');
472 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
473 // SuperAdministrator access only
474 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
475 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">';
476 } else {
477 $htmltext = $langs->trans("ContactSuperAdminForChange");
478 print $form->textwithpicto(getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET'), $htmltext, 1, 'superadmin');
479 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.'">';
480 }
481 print '</td></tr>';
482 }
483
484 // PW
485 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
486 $mainsmtppw = getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET');
487 print '<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
488 // SuperAdministrator access only
489 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
490 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
491 } else {
492 $htmltext = $langs->trans("ContactSuperAdminForChange");
493 print $form->textwithpicto(getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET'), $htmltext, 1, 'superadmin');
494 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.'">';
495 }
496 print '</td></tr>';
497 }
498
499 // OAUTH service provider
500 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
501 print '<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
502 // SuperAdministrator access only
503 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
504 print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET'));
505 } else {
506 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET')];
507 if (empty($text)) {
508 $text = $langs->trans("Undefined");
509 }
510 $htmltext = $langs->trans("ContactSuperAdminForChange");
511 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
512 print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' . getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').'">';
513 }
514 print '</td></tr>';
515 }
516
517 // TLS
518 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
519 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
520 if (function_exists('openssl_open')) {
521 print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET') ? getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET') : 0), 1);
522 } else {
523 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
524 }
525 } else {
526 print yn(0).' ('.$langs->trans("NotSupported").')';
527 }
528 print '</td></tr>';
529
530 // STARTTLS
531 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
532 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
533 if (function_exists('openssl_open')) {
534 print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET') ? getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET') : 0), 1);
535 } else {
536 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
537 }
538 } else {
539 print yn(0).' ('.$langs->trans("NotSupported").')';
540 }
541 print '</td></tr>';
542
543 // SMTP_ALLOW_SELF_SIGNED_TICKET
544 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
545 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
546 if (function_exists('openssl_open')) {
547 print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ? getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') : 0), 1);
548 } else {
549 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
550 }
551 } else {
552 print yn(0).' ('.$langs->trans("NotSupported").')';
553 }
554 print '</td></tr>';
555
556 print '</table>';
557
558 print dol_get_fiche_end();
559
560 print $form->buttonsSaveCancel();
561
562 print '</form>';
563} else {
564 print dol_get_fiche_head($head, 'common_ticket', '', -1);
565
566 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
567 print "<br>\n";
568
569 print '<div class="neutral nomargintop">';
570 print $langs->trans("MAIN_DISABLE_ALL_MAILS");
571 if (!empty($conf->use_javascript_ajax)) {
572 print ajax_constantonoff('MAIN_DISABLE_ALL_MAILS', array(), null, 0, 0, 1, 2, 0, 0, '_red').'</a>';
573 } else {
574 print yn(getDolGlobalString('MAIN_DISABLE_ALL_MAILS'));
575 if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
576 print img_warning($langs->trans("Disabled"));
577 }
578 }
579 print '</div>';
580 print "<br>\n";
581
582 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
583 print '<table class="noborder centpercent">';
584 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
585
586 // Method
587 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
588 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
589 if (empty($text)) {
590 $text = $langs->trans("Undefined").img_warning();
591 }
592 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') {
593 print '<span class="opacitymedium">'.$text.'</span>';
594 } else {
595 print $text;
596 }
597 print '</td></tr>';
598
599 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
600 // Host server
601 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
602 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
603 } else {
604 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_TICKET').'</td></tr>';
605 }
606
607 // Port
608 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
609 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
610 } else {
611 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ? ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTP_PORT_TICKET').'</td></tr>';
612 }
613
614 // AUTH method
615 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
616 $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
617 $text = '';
618 if ($authtype === "LOGIN") {
619 $text = $langs->trans("UseAUTHLOGIN");
620 } elseif ($authtype === "PLAIN") {
621 $text = $langs->trans("UseAUTHPLAIN");
622 } elseif ($authtype === "XOAUTH2") {
623 $text = $langs->trans("UseOauth");
624 }
625 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
626 }
627
628 // SMTPS ID
629 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
630 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET').'</td></tr>';
631 }
632
633 // SMTPS PW
634 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") {
635 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET')).'</td></tr>';
636 }
637
638 // SMTPS oauth service
639 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') === "XOAUTH2") {
640 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET')];
641 if (empty($text)) {
642 $text = $langs->trans("Undefined").img_warning();
643 }
644 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
645 }
646
647 // TLS
648 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
649 // Nothing
650 } else {
651 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
652 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
653 if (function_exists('openssl_open')) {
654 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET'));
655 } else {
656 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
657 }
658 } else {
659 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
660 }
661 print '</td></tr>';
662 }
663
664 // STARTTLS
665 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
666 // Nothing
667 } else {
668 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
669 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
670 if (function_exists('openssl_open')) {
671 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET'));
672 } else {
673 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
674 }
675 } else {
676 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
677 }
678 print '</td></tr>';
679 }
680
681 // SMTP_ALLOW_SELF_SIGNED_EMAILING
682 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
683 // Nothing
684 } else {
685 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
686 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
687 if (function_exists('openssl_open')) {
688 print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET'));
689 } else {
690 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
691 }
692 } else {
693 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
694 }
695 print '</td></tr>';
696 }
697 }
698
699 print '</table>';
700
701 print '</div>';
702
703 print dol_get_fiche_end();
704
705
706 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA')) {
707 print '<br>';
708 /*
709 // Warning 1
710 if ($linuxlike) {
711 $sendmailoption=ini_get('mail.force_extra_parameters');
712 if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
713 {
714 print info_admin($langs->trans("SendmailOptionNotComplete"));
715 }
716 }*/
717 // Warning 2
718 print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
719 }
720
721
722 // Buttons for actions
723
724 print '<div class="tabsAction">';
725
726 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
727
728 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
729 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'mail' || !$linuxlike) {
730 if (function_exists('fsockopen') && $port && $server) {
731 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&token='.newToken().'">'.$langs->trans("DoTestServerAvailability").'</a>';
732 }
733 } else {
734 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
735 }
736
737 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init">'.$langs->trans("DoTestSend").'</a>';
738
739 if (isModEnabled('fckeditor')) {
740 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
741 }
742 }
743
744 print '</div>';
745
746
747 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
748 $text = $langs->trans("WarningPHPMail", $listofmethods['mail'], $listofmethods['smtps']);
749 print info_admin($text);
750 }
751
752 // Run the test to connect
753 if ($action == 'testconnect') {
754 print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
755 print load_fiche_titre($langs->trans("DoTestServerAvailability"));
756
757 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
758 $mail = new CMailFile('test', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext);
759
760 $errormsg = '';
761
762 $listOfAllowedPorts = array('25', '465', '587', '2525');
763 if (!in_array((string) $port, $listOfAllowedPorts)) {
764 $errormsg = $langs->trans("Testing the SMTP port on different ports than ".implode(', ', $listOfAllowedPorts)." is not allowed.");
765 }
766
767 if (empty($errormsg)) {
768 $result = $mail->check_server_port((string) $server, (int) $port);
769 if ($result && !is_array($result)) {
770 print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'</div>';
771 } else {
772 $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port);
773 if (is_array($result)) {
774 $errormsg .= '<br>'.$result['content'];
775 }
776 }
777 }
778
779 if ($errormsg) {
780 if ($mail->error) {
781 $errormsg .= ' - '.$mail->error;
782 }
783
784 setEventMessages($errormsg, null, 'errors');
785 }
786
787 print '<br>';
788 }
789
790 // Show email send test form
791 if ($action == 'test' || $action == 'testhtml') {
792 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
793 print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
794
795 print dol_get_fiche_head(array(), '', '', -1);
796
797 // Cree l'objet formulaire mail
798 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
799 $formmail = new FormMail($db);
800 $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
801 $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
802 $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
803 $formmail->fromid = $user->id;
804 $formmail->fromalsorobot = 1;
805 $formmail->withfromreadonly = 0;
806 $formmail->withsubstit = 0;
807 $formmail->withfrom = 1;
808 $formmail->witherrorsto = 1;
809 $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
810 $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1);
811 $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1);
812 $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
813 $formmail->withtopicreadonly = 0;
814 $formmail->withfile = 2;
815 $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
816 $formmail->withbodyreadonly = 0;
817 $formmail->withcancel = 1;
818 $formmail->withdeliveryreceipt = 1;
819 $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
820 $formmail->ckeditortoolbar = 'dolibarr_mailings';
821 // Tableau des substitutions
822 $formmail->substit = $substitutionarrayfortest;
823 // Tableau des parameters complementaires du post
824 $formmail->param["action"] = "send";
825 $formmail->param["models"] = "body";
826 $formmail->param["mailid"] = 0;
827 $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
828
829 // Init list of files
830 if (GETPOST("mode", "aZ09") == 'init') {
831 $formmail->clear_attached_files();
832 }
833
834 print $formmail->get_form('addfile', 'removefile');
835
836 print dol_get_fiche_end();
837 }
838}
839
840// End of page
841llxFooter();
842$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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 information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage generation of HTML components Only common components must be here.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.