dolibarr 21.0.0-alpha
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 Frédéric France <frederic.france@free.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$usersignature = $user->signature;
39// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
40if ($action == 'test' || $action == 'send') {
41 $usersignature = dol_string_nohtmltag($usersignature, 2);
42}
43
44$substitutionarrayfortest = array(
45 '__ID__' => 'TESTIdRecord',
46 '__USER_LOGIN__' => $user->login,
47 '__USER_EMAIL__' => $user->email,
48 '__USER_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
49 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
50 '__LASTNAME__' => 'RecipientLastname',
51 '__FIRSTNAME__' => 'RecipientFirstname',
52 '__ADDRESS__' => 'RecipientAddress',
53 '__ZIP__' => 'RecipientZip',
54 '__TOWN_' => 'RecipientTown',
55 '__COUNTRY__' => 'RecipientCountry',
56 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
57);
58complete_substitutions_array($substitutionarrayfortest, $langs);
59
60// List of sending methods
61$listofmethods = array();
62$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
63$listofmethods['mail'] = 'PHP mail function';
64//$listofmethods['simplemail']='Simplemail class';
65$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
66if (version_compare(phpversion(), '7.0', '>=')) {
67 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
68}
69
70// Security check
71if (!$user->admin) {
73}
74
75
76/*
77 * Actions
78 */
79
80if ($action == 'update' && !$cancel) {
81 // Send mode parameters
82 dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity);
83 dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
84 dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
85 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
86 if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_TICKET")) {
87 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET", 'password'), 'chaine', 0, '', $conf->entity);
88 }
89 if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
90 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
91 }
92 if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
93 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
94 }
95 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
96 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
97 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);
98
99 header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
100 exit;
101}
102
103
104// Actions to send emails
105$id = 0;
106$actiontypecode = ''; // Not an event for agenda
107$triggersendname = ''; // Disable triggers
108$paramname = 'id';
109$mode = 'emailfortest';
110$trackid = (($action == 'testhtml') ? "testhtml" : "test");
111$sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket
112include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
113
114if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
115 $action = 'test';
116}
117if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
118 $action = 'testhtml';
119}
120
121
122
123
124/*
125 * View
126 */
127
128$form = new Form($db);
129
130$linuxlike = 1;
131if (preg_match('/^win/i', PHP_OS)) {
132 $linuxlike = 0;
133}
134if (preg_match('/^mac/i', PHP_OS)) {
135 $linuxlike = 0;
136}
137
138if (!getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')) {
139 $conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
140}
141$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', (int) ini_get('smtp_port'));
142if (!$port) {
143 $port = 25;
144}
145$server = getDolGlobalString('MAIN_MAIL_SMTP_SERVER_TICKET', ini_get('SMTP'));
146if (!$server) {
147 $server = '127.0.0.1';
148}
149
150
151$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
152llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-mails_ticket');
153
154print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
155
157
158// List of oauth services
159$oauthservices = array();
160
161foreach ($conf->global as $key => $val) {
162 if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
163 $key = preg_replace('/^OAUTH_/', '', $key);
164 $key = preg_replace('/_ID$/', '', $key);
165 if (preg_match('/^.*-/', $key)) {
166 $name = preg_replace('/^.*-/', '', $key);
167 } else {
168 $name = $langs->trans("NoName");
169 }
170 $provider = preg_replace('/-.*$/', '', $key);
171 $provider = ucfirst(strtolower($provider));
172
173 $oauthservices[$key] = $name." (".$provider.")";
174 }
175}
176
177
178if ($action == 'edit') {
179 if ($conf->use_javascript_ajax) {
180 print "\n".'<script type="text/javascript">';
181 print 'jQuery(document).ready(function () {
182 function initfields()
183 {
184 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
185 {
186 jQuery(".hideifdefault").hide();
187 }
188 else
189 {
190 jQuery(".hideifdefault").show();
191 }
192
193 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
194 {
195 console.log("I choose php mail mode");
196 jQuery(".drag").hide();
197 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
198 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
199 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
200 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
201 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(0);
202 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").prop("disabled", true);
203 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
204 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
205 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
206 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
207 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
208 jQuery(".smtp_method").hide();
209 jQuery(".dkim").hide();
210 jQuery(".smtp_auth_method").hide();
211 ';
212 if ($linuxlike) {
213 print '
214 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
215 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
216 jQuery("#smtp_server_mess").show();
217 jQuery("#smtp_port_mess").show();
218 ';
219 } else {
220 print '
221 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
222 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
223 jQuery("#smtp_server_mess").hide();
224 jQuery("#smtp_port_mess").hide();
225 ';
226 }
227 print '
228 }
229 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
230 {
231 console.log("I choose smtps mail mode");
232 jQuery(".drag").show();
233 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
234 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
235 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET').');
236 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
237 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').');
238 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
239 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
240 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
241 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
242 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
247 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
250 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
251 jQuery("#smtp_server_mess").hide();
252 jQuery("#smtp_port_mess").hide();
253 jQuery(".smtp_method").show();
254 jQuery(".dkim").hide();
255 jQuery(".smtp_auth_method").show();
256 }
257 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
258 {
259 console.log("I choose swiftmailer mail mode");
260 jQuery(".drag").show();
261 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').');
262 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
263 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET').');
264 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
265 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').');
266 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
270 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
271 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
272 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
273 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
274 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
275 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
278 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
279 jQuery("#smtp_server_mess").hide();
280 jQuery("#smtp_port_mess").hide();
281 jQuery(".smtp_method").show();
282 jQuery(".dkim").show();
283 jQuery(".smtp_auth_method").show();
284 }
285 }
286 function change_smtp_auth_method() {
287 console.log("Call smtp auth method "+jQuery("#MAIN_MAIL_SENDMODE_TICKET").val());
288 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\') {
289 if (jQuery("#radio_oauth").prop("checked")) {
290 jQuery(".smtp_pw").hide();
291 jQuery(".smtp_oauth_service").show();
292 } else {
293 jQuery(".smtp_pw").show();
294 jQuery(".smtp_oauth_service").hide();
295 }
296 } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\') {
297 if (jQuery("#radio_oauth").prop("checked")) {
298 jQuery(".smtp_pw").hide();
299 jQuery(".smtp_oauth_service").show();
300 } else {
301 jQuery(".smtp_pw").show();
302 jQuery(".smtp_oauth_service").hide();
303 }
304 } else {
305 jQuery(".smtp_pw").hide();
306 jQuery(".smtp_oauth_service").hide();
307 }
308 }
309
310 initfields();
311 change_smtp_auth_method();
312
313 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
314 initfields();
315 change_smtp_auth_method();
316 });
317 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
318 change_smtp_auth_method();
319 });
320 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
321 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
322 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
323 });
324 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
325 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
326 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
327 });
328 })';
329 print '</script>'."\n";
330 }
331
332 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
333 print '<input type="hidden" name="token" value="'.newToken().'">';
334 print '<input type="hidden" name="action" value="update">';
335
336 print dol_get_fiche_head($head, 'common_ticket', '', -1);
337
338 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
339 print "<br><br>\n";
340
341
342 clearstatcache();
343
344 print '<table class="noborder centpercent">';
345 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
346
347 // Method
348
349 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
350
351 // SuperAdministrator access only
352 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
353 print $form->selectarray('MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
354 } else {
355 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
356 if (empty($text)) {
357 $text = $langs->trans("Undefined");
358 }
359 $htmltext = $langs->trans("ContactSuperAdminForChange");
360 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
361 print '<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="' . getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET').'">';
362 }
363 print '</td></tr>';
364
365 // Host server
366
367 print '<tr class="oddeven hideifdefault">';
368 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail') {
369 print '<td>';
370 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
371 print '</td><td>';
372 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
373 print '</td>';
374 } else {
375 print '<td>';
376 $mainserver = (getDolGlobalString('MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '');
377 $smtpserver = ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined");
378 if ($linuxlike) {
379 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
380 } else {
381 print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
382 }
383 print '</td><td>';
384 // SuperAdministrator access only
385 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
386 print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.'">';
387 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.'">';
388 print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
389 print ' <span class="opacitymedium smtp_method">' . $langs->trans("SeeLinkToOnlineDocumentation") . '</span>';
390 } else {
391 $text = !empty($mainserver) ? $mainserver : $smtpserver;
392 $htmltext = $langs->trans("ContactSuperAdminForChange");
393 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
394 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.'">';
395 }
396 print '</td>';
397 }
398 print '</tr>';
399
400 // Port
401
402 print '<tr class="oddeven hideifdefault hideonmodemail"><td>';
403 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail') {
404 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
405 print '</td><td>';
406 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
407 } else {
408 $mainport = (getDolGlobalString('MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '');
409 $smtpport = ini_get('smtp_port') ? ini_get('smtp_port') : $langs->transnoentities("Undefined");
410 if ($linuxlike) {
411 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
412 } else {
413 print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
414 }
415 print '</td><td>';
416 // SuperAdministrator access only
417 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
418 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.'">';
419 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.'">';
420 print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
421 } else {
422 $text = (!empty($mainport) ? $mainport : $smtpport);
423 $htmltext = $langs->trans("ContactSuperAdminForChange");
424 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
425 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.'">';
426 }
427 }
428 print '</td></tr>';
429
430 // AUTH method
431 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
432 print '<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
433 $vartosmtpstype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET';
434 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
435 // 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)
436 print '<input type="radio" id="radio_pw" name="'.$vartosmtpstype.'" value="LOGIN"'.(getDolGlobalString($vartosmtpstype, 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
437 print '<label for="radio_pw" >'.$langs->trans("UseAUTHLOGIN").'</label>';
438 print '<br>';
439 print '<input type="radio" id="radio_plain" name="'.$vartosmtpstype.'" value="PLAIN"'.(getDolGlobalString($vartosmtpstype, 'PLAIN') == 'PLAIN' ? ' checked' : '').'> ';
440 print '<label for="radio_plain" >'.$langs->trans("UseAUTHPLAIN").'</label>';
441 print '<br>';
442 print '<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.'" value="XOAUTH2"'.(getDolGlobalString($vartosmtpstype) == 'XOAUTH2' ? ' checked' : '').(isModEnabled('oauth') ? '' : ' disabled').'> ';
443 print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
444 if (!isModEnabled('oauth')) {
445 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword=oauth">'.$langs->trans("EnableModuleX", "OAuth").'</a>';
446 } else {
447 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/oauth.php">'.$langs->trans("SetupModuleX", " OAuth").'</a>';
448 }
449 } else {
450 $value = getDolGlobalString($vartosmtpstype, 'LOGIN');
451 $htmltext = $langs->trans("ContactSuperAdminForChange");
452 print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
453 print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.'">';
454 }
455 print '</td></tr>';
456 }
457
458 // ID
459 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
460 $mainstmpid = (getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : '');
461 print '<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
462 // SuperAdministrator access only
463 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
464 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.'">';
465 } else {
466 $htmltext = $langs->trans("ContactSuperAdminForChange");
467 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1, 'superadmin');
468 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.'">';
469 }
470 print '</td></tr>';
471 }
472
473 // PW
474 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
475 $mainsmtppw = getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET');
476 print '<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
477 // SuperAdministrator access only
478 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
479 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.'">';
480 } else {
481 $htmltext = $langs->trans("ContactSuperAdminForChange");
482 print $form->textwithpicto(getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET'), $htmltext, 1, 'superadmin');
483 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.'">';
484 }
485 print '</td></tr>';
486 }
487
488 // OAUTH service provider
489 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
490 print '<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
491 // SuperAdministrator access only
492 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
493 print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
494 } else {
495 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET')];
496 if (empty($text)) {
497 $text = $langs->trans("Undefined");
498 }
499 $htmltext = $langs->trans("ContactSuperAdminForChange");
500 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
501 print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' . getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').'">';
502 }
503 print '</td></tr>';
504 }
505
506 // TLS
507 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
508 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
509 if (function_exists('openssl_open')) {
510 print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
511 } else {
512 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
513 }
514 } else {
515 print yn(0).' ('.$langs->trans("NotSupported").')';
516 }
517 print '</td></tr>';
518
519 // STARTTLS
520 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
521 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
522 if (function_exists('openssl_open')) {
523 print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
524 } else {
525 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
526 }
527 } else {
528 print yn(0).' ('.$langs->trans("NotSupported").')';
529 }
530 print '</td></tr>';
531
532 // SMTP_ALLOW_SELF_SIGNED_TICKET
533 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
534 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
535 if (function_exists('openssl_open')) {
536 print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET : 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 print '</table>';
546
547 print dol_get_fiche_end();
548
549 print $form->buttonsSaveCancel();
550
551 print '</form>';
552} else {
553 print dol_get_fiche_head($head, 'common_ticket', '', -1);
554
555 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
556 print "<br><br>\n";
557
558 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
559 print '<table class="noborder centpercent">';
560 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
561
562 // Method
563 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
564 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')];
565 if (empty($text)) {
566 $text = $langs->trans("Undefined").img_warning();
567 }
568 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') {
569 print '<span class="opacitymedium">'.$text.'</span>';
570 } else {
571 print $text;
572 }
573 print '</td></tr>';
574
575 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
576 // Host server
577 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
578 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
579 } else {
580 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') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : '').'</td></tr>';
581 }
582
583 // Port
584 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
585 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
586 } else {
587 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') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'</td></tr>';
588 }
589
590 // AUTH method
591 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
592 $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
593 $text = '';
594 if ($authtype === "LOGIN") {
595 $text = $langs->trans("UseAUTHLOGIN");
596 } elseif ($authtype === "PLAIN") {
597 $text = $langs->trans("UseAUTHPLAIN");
598 } elseif ($authtype === "XOAUTH2") {
599 $text = $langs->trans("UseOauth");
600 }
601 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
602 }
603
604 // SMTPS ID
605 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
606 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>' . getDolGlobalString('MAIN_MAIL_SMTPS_ID_TICKET').'</td></tr>';
607 }
608
609 // SMTPS PW
610 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") {
611 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET')).'</td></tr>';
612 }
613
614 // SMTPS oauth service
615 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') === "XOAUTH2") {
616 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET')];
617 if (empty($text)) {
618 $text = $langs->trans("Undefined").img_warning();
619 }
620 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
621 }
622
623 // TLS
624 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
625 // Nothing
626 } else {
627 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
628 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
629 if (function_exists('openssl_open')) {
630 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET'));
631 } else {
632 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
633 }
634 } else {
635 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
636 }
637 print '</td></tr>';
638 }
639
640 // STARTTLS
641 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
642 // Nothing
643 } else {
644 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
645 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
646 if (function_exists('openssl_open')) {
647 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_TICKET'));
648 } else {
649 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
650 }
651 } else {
652 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
653 }
654 print '</td></tr>';
655 }
656
657 // SMTP_ALLOW_SELF_SIGNED_EMAILING
658 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
659 // Nothing
660 } else {
661 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
662 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
663 if (function_exists('openssl_open')) {
664 print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET'));
665 } else {
666 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
667 }
668 } else {
669 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
670 }
671 print '</td></tr>';
672 }
673 }
674
675 print '</table>';
676 print '</div>';
677
678 print dol_get_fiche_end();
679
680
681 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA')) {
682 print '<br>';
683 /*
684 // Warning 1
685 if ($linuxlike) {
686 $sendmailoption=ini_get('mail.force_extra_parameters');
687 if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
688 {
689 print info_admin($langs->trans("SendmailOptionNotComplete"));
690 }
691 }*/
692 // Warning 2
693 print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
694 }
695
696
697 // Buttons for actions
698
699 print '<div class="tabsAction">';
700
701 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
702
703 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
704 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'mail' || !$linuxlike) {
705 if (function_exists('fsockopen') && $port && $server) {
706 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
707 }
708 } else {
709 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
710 }
711
712 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
713
714 if (isModEnabled('fckeditor')) {
715 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
716 }
717 }
718
719 print '</div>';
720
721
722 if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
723 $text = $langs->trans("WarningPHPMail", $listofmethods['mail'], $listofmethods['smtps']);
724 print info_admin($text);
725 }
726
727 // Run the test to connect
728 if ($action == 'testconnect') {
729 print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
730 print load_fiche_titre($langs->trans("DoTestServerAvailability"));
731
732 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
733 $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext);
734
735 $result = $mail->check_server_port($server, $port);
736 if ($result) {
737 print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
738 } else {
739 $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
740
741 if ($mail->error) {
742 $errormsg .= ' - '.$mail->error;
743 }
744
745 setEventMessages($errormsg, null, 'errors');
746 }
747 print '<br>';
748 }
749
750 // Show email send test form
751 if ($action == 'test' || $action == 'testhtml') {
752 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
753 print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
754
755 print dol_get_fiche_head(array(), '', '', -1);
756
757 // Cree l'objet formulaire mail
758 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
759 $formmail = new FormMail($db);
760 $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
761 $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
762 $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
763 $formmail->fromid = $user->id;
764 $formmail->fromalsorobot = 1;
765 $formmail->withfromreadonly = 0;
766 $formmail->withsubstit = 0;
767 $formmail->withfrom = 1;
768 $formmail->witherrorsto = 1;
769 $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
770 $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1);
771 $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1);
772 $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
773 $formmail->withtopicreadonly = 0;
774 $formmail->withfile = 2;
775 $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
776 $formmail->withbodyreadonly = 0;
777 $formmail->withcancel = 1;
778 $formmail->withdeliveryreceipt = 1;
779 $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
780 $formmail->ckeditortoolbar = 'dolibarr_mailings';
781 // Tableau des substitutions
782 $formmail->substit = $substitutionarrayfortest;
783 // Tableau des parameters complementaires du post
784 $formmail->param["action"] = "send";
785 $formmail->param["models"] = "body";
786 $formmail->param["mailid"] = 0;
787 $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
788
789 // Init list of files
790 if (GETPOST("mode", "aZ09") == 'init') {
791 $formmail->clear_attached_files();
792 }
793
794 print $formmail->get_form('addfile', 'removefile');
795
796 print dol_get_fiche_end();
797 }
798}
799
800// End of page
801llxFooter();
802$db->close();
$id
Definition account.php:39
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.
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:70
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...
llxFooter()
Footer empty.
Definition document.php:107
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").
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_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'.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.