dolibarr 23.0.3
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"]).'">';
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><br>\n";
568
569 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
570 print '<table class="noborder centpercent">';
571 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
572
573 // Method
574 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
575 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
576 if (empty($text)) {
577 $text = $langs->trans("Undefined").img_warning();
578 }
579 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') {
580 print '<span class="opacitymedium">'.$text.'</span>';
581 } else {
582 print $text;
583 }
584 print '</td></tr>';
585
586 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
587 // Host server
588 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
589 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
590 } else {
591 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>';
592 }
593
594 // Port
595 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
596 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
597 } else {
598 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>';
599 }
600
601 // AUTH method
602 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
603 $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
604 $text = '';
605 if ($authtype === "LOGIN") {
606 $text = $langs->trans("UseAUTHLOGIN");
607 } elseif ($authtype === "PLAIN") {
608 $text = $langs->trans("UseAUTHPLAIN");
609 } elseif ($authtype === "XOAUTH2") {
610 $text = $langs->trans("UseOauth");
611 }
612 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
613 }
614
615 // SMTPS ID
616 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
617 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET').'</td></tr>';
618 }
619
620 // SMTPS PW
621 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") {
622 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET')).'</td></tr>';
623 }
624
625 // SMTPS oauth service
626 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') === "XOAUTH2") {
627 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET')];
628 if (empty($text)) {
629 $text = $langs->trans("Undefined").img_warning();
630 }
631 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
632 }
633
634 // TLS
635 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
636 // Nothing
637 } else {
638 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
639 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
640 if (function_exists('openssl_open')) {
641 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET'));
642 } else {
643 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
644 }
645 } else {
646 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
647 }
648 print '</td></tr>';
649 }
650
651 // STARTTLS
652 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
653 // Nothing
654 } else {
655 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
656 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
657 if (function_exists('openssl_open')) {
658 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET'));
659 } else {
660 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
661 }
662 } else {
663 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
664 }
665 print '</td></tr>';
666 }
667
668 // SMTP_ALLOW_SELF_SIGNED_EMAILING
669 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
670 // Nothing
671 } else {
672 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
673 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
674 if (function_exists('openssl_open')) {
675 print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET'));
676 } else {
677 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
678 }
679 } else {
680 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
681 }
682 print '</td></tr>';
683 }
684 }
685
686 print '</table>';
687
688 print '</div>';
689
690 print dol_get_fiche_end();
691
692
693 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA')) {
694 print '<br>';
695 /*
696 // Warning 1
697 if ($linuxlike) {
698 $sendmailoption=ini_get('mail.force_extra_parameters');
699 if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
700 {
701 print info_admin($langs->trans("SendmailOptionNotComplete"));
702 }
703 }*/
704 // Warning 2
705 print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
706 }
707
708
709 // Buttons for actions
710
711 print '<div class="tabsAction">';
712
713 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
714
715 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
716 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'mail' || !$linuxlike) {
717 if (function_exists('fsockopen') && $port && $server) {
718 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
719 }
720 } else {
721 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
722 }
723
724 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
725
726 if (isModEnabled('fckeditor')) {
727 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
728 }
729 }
730
731 print '</div>';
732
733
734 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
735 $text = $langs->trans("WarningPHPMail", $listofmethods['mail'], $listofmethods['smtps']);
736 print info_admin($text);
737 }
738
739 // Run the test to connect
740 if ($action == 'testconnect') {
741 print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
742 print load_fiche_titre($langs->trans("DoTestServerAvailability"));
743
744 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
745 $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext);
746
747 $result = $mail->check_server_port((string) $server, (int) $port);
748 if ($result) {
749 print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'</div>';
750 } else {
751 $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port);
752
753 if ($mail->error) {
754 $errormsg .= ' - '.$mail->error;
755 }
756
757 setEventMessages($errormsg, null, 'errors');
758 }
759 print '<br>';
760 }
761
762 // Show email send test form
763 if ($action == 'test' || $action == 'testhtml') {
764 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
765 print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
766
767 print dol_get_fiche_head(array(), '', '', -1);
768
769 // Cree l'objet formulaire mail
770 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
771 $formmail = new FormMail($db);
772 $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
773 $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
774 $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
775 $formmail->fromid = $user->id;
776 $formmail->fromalsorobot = 1;
777 $formmail->withfromreadonly = 0;
778 $formmail->withsubstit = 0;
779 $formmail->withfrom = 1;
780 $formmail->witherrorsto = 1;
781 $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
782 $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1);
783 $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1);
784 $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
785 $formmail->withtopicreadonly = 0;
786 $formmail->withfile = 2;
787 $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
788 $formmail->withbodyreadonly = 0;
789 $formmail->withcancel = 1;
790 $formmail->withdeliveryreceipt = 1;
791 $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
792 $formmail->ckeditortoolbar = 'dolibarr_mailings';
793 // Tableau des substitutions
794 $formmail->substit = $substitutionarrayfortest;
795 // Tableau des parameters complementaires du post
796 $formmail->param["action"] = "send";
797 $formmail->param["models"] = "body";
798 $formmail->param["mailid"] = 0;
799 $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
800
801 // Init list of files
802 if (GETPOST("mode", "aZ09") == 'init') {
803 $formmail->clear_attached_files();
804 }
805
806 print $formmail->get_form('addfile', 'removefile');
807
808 print dol_get_fiche_end();
809 }
810}
811
812// End of page
813llxFooter();
814$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 permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
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").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.