dolibarr 22.0.5
mails_emailing.php
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');
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__' => 'RecipientIdRecord',
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 //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
60 '__LASTNAME__' => 'RecipientLastname',
61 '__FIRSTNAME__' => 'RecipientFirstname',
62 '__ADDRESS__' => 'RecipientAddress',
63 '__ZIP__' => 'RecipientZip',
64 '__TOWN_' => 'RecipientTown',
65 '__COUNTRY__' => 'RecipientCountry',
66 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
67 '__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefinedtag&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')."-undefinedtag", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0"/>'
68);
69complete_substitutions_array($substitutionarrayfortest, $langs);
70
71// List of sending methods
72$listofmethods = array();
73$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
74$listofmethods['mail'] = 'PHP mail function';
75//$listofmethods['simplemail']='Simplemail class';
76$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
77if (version_compare(phpversion(), '7.0', '>=')) {
78 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
79}
80
81// Security check
82if (!$user->admin) {
84}
85
86
87/*
88 * Actions
89 */
90
91if ($action == 'update' && !$cancel) {
92 // Send mode parameters
93 dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity);
94 dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity);
95 dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity);
96 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine', 0, '', $conf->entity);
97 if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_EMAILING")) {
98 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING", 'password'), 'chaine', 0, '', $conf->entity);
99 }
100 if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
101 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
102 }
103 if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
104 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
105 }
106 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"), 'chaine', 0, '', $conf->entity);
107 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"), 'chaine', 0, '', $conf->entity);
108 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"), 'chaine', 0, '', $conf->entity);
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 = 'emailing'; // Force to use dedicated context of setup for emailing
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_EMAILING')) {
150 $conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default';
151}
152$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_EMAILING', (int) ini_get('smtp_port'));
153if (!$port) {
154 $port = 25;
155}
156$server = getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING', 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_emailing');
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
188if ($action == 'edit') {
189 if ($conf->use_javascript_ajax) {
190 print "\n".'<script type="text/javascript">';
191 print 'jQuery(document).ready(function () {
192 function initfields()
193 {
194 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\')
195 {
196 jQuery(".hideifdefault").hide();
197 }
198 else
199 {
200 jQuery(".hideifdefault").show();
201 }
202
203 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\')
204 {
205 console.log("I choose php mail mode");
206 jQuery(".drag").hide();
207 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
208 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true);
209 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
210 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
211 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
212 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
213 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
214 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
215 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
216 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
217 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
218 jQuery(".smtp_method").hide();
219 jQuery(".dkim").hide();
220 jQuery(".smtp_auth_method").hide();
221 ';
222 if ($linuxlike) {
223 print '
224 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").hide();
225 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").hide();
226 jQuery("#smtp_server_mess").show();
227 jQuery("#smtp_port_mess").show();
228 ';
229 } else {
230 print '
231 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").prop("disabled", true);
232 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").prop("disabled", true);
233 jQuery("#smtp_server_mess").hide();
234 jQuery("#smtp_port_mess").hide();
235 ';
236 }
237 print '
238 }
239 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\')
240 {
241 console.log("I choose smtps mail mode");
242 jQuery(".drag").show();
243 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').');
244 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
245 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING').');
246 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').');
248 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
249 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
250 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").hide();
255 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").hide();
256 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").hide();
257 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
258 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
260 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
261 jQuery("#smtp_port_mess").hide();
262 jQuery("#smtp_server_mess").hide();
263 jQuery(".smtp_method").show();
264 jQuery(".dkim").hide();
265 jQuery(".smtp_auth_method").show();
266 }
267 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
268 {
269 console.log("I choose swiftmailer mail mode");
270 jQuery(".drag").show();
271 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').');
272 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled");
273 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING').');
274 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").removeAttr("disabled");
275 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING').');
276 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").val(0);
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_EMAILING").prop("disabled", true);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").prop("disabled", true);
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").prop("disabled", true);
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_EMAILING").hide();
283 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_EMAILING").hide();
284 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_EMAILING").hide();
285 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").removeAttr("disabled");
286 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
288 jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
289 jQuery("#smtp_server_mess").hide();
290 jQuery("#smtp_port_mess").hide();
291 jQuery(".smtp_method").show();
292 jQuery(".dkim").show();
293 jQuery(".smtp_auth_method").show();
294 }
295 }
296 function change_smtp_auth_method() {
297 console.log("Call smtp auth method");
298 if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\') {
299 if (jQuery("#radio_oauth").prop("checked")) {
300 jQuery(".smtp_pw").hide();
301 jQuery(".smtp_oauth_service").show();
302 } else {
303 jQuery(".smtp_pw").show();
304 jQuery(".smtp_oauth_service").hide();
305 }
306 } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\') {
307 if (jQuery("#radio_oauth").prop("checked")) {
308 jQuery(".smtp_pw").hide();
309 jQuery(".smtp_oauth_service").show();
310 } else {
311 jQuery(".smtp_pw").show();
312 jQuery(".smtp_oauth_service").hide();
313 }
314 } else {
315 jQuery(".smtp_pw").hide();
316 jQuery(".smtp_oauth_service").hide();
317 }
318 }
319
320 change_smtp_auth_method();
321 initfields();
322
323 jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
324 change_smtp_auth_method();
325 initfields();
326 });
327 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
328 change_smtp_auth_method();
329 });
330 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
331 if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
332 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
333 else
334 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
335 });
336 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").change(function() {
337 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val() == 1)
338 jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0);
339 else
340 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
341 });
342 })';
343 print '</script>'."\n";
344 }
345
346 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
347 print '<input type="hidden" name="token" value="'.newToken().'">';
348 print '<input type="hidden" name="action" value="update">';
349
350 print dol_get_fiche_head($head, 'common_emailing', '', -1);
351
352 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
353 print "<br><br>\n";
354
355
356 clearstatcache();
357
358 print '<table class="noborder centpercent">';
359 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
360
361 // Method
362
363 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
364
365 // SuperAdministrator access only
366 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
367 print $form->selectarray('MAIN_MAIL_SENDMODE_EMAILING', $listofmethods, getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'));
368 } else {
369 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
370 if (empty($text)) {
371 $text = $langs->trans("Undefined");
372 }
373 $htmltext = $langs->trans("ContactSuperAdminForChange");
374 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
375 print '<input type="hidden" name="MAIN_MAIL_SENDMODE_EMAILING" value="' . getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING').'">';
376 }
377 print '</td></tr>';
378
379 // Host server
380
381 print '<tr class="oddeven hideifdefault">';
382 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail') {
383 print '<td>';
384 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
385 print '</td><td>';
386 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
387 print '</td>';
388 } else {
389 print '<td>';
390 $mainserver = getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING');
391 $smtpserver = ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined");
392 if ($linuxlike) {
393 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
394 } else {
395 print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
396 }
397 print '</td><td>';
398 // SuperAdministrator access only
399 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
400 print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="' . $mainserver . '">';
401 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="' . $mainserver . '">';
402 print '<span id="smtp_server_mess" class="opacitymedium">' . $langs->trans("SeeLocalSendMailSetup") . '</span>';
403 print ' <span class="opacitymedium smtp_method">' . $langs->trans("SeeLinkToOnlineDocumentation") . '</span>';
404 } else {
405 $text = !empty($mainserver) ? $mainserver : $smtpserver;
406 $htmltext = $langs->trans("ContactSuperAdminForChange");
407 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
408 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="' . $mainserver . '">';
409 }
410 print '</td>';
411 }
412 print '</tr>';
413
414 // Port
415
416 print '<tr class="oddeven hideifdefault hideonmodemail"><td>';
417 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail') {
418 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
419 print '</td><td>';
420 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
421 } else {
422 $mainport = getDolGlobalString('MAIN_MAIL_SMTP_PORT_EMAILING');
423 $smtpport = ini_get('smtp_port') ? ini_get('smtp_port') : $langs->transnoentities("Undefined");
424 if ($linuxlike) {
425 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
426 } else {
427 print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
428 }
429 print '</td><td>';
430 // SuperAdministrator access only
431 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
432 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="' . $mainport . '">';
433 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="' . $mainport . '">';
434 print '<span id="smtp_port_mess" class="opacitymedium">' . $langs->trans("SeeLocalSendMailSetup") . '</span>';
435 } else {
436 $text = (!empty($mainport) ? $mainport : $smtpport);
437 $htmltext = $langs->trans("ContactSuperAdminForChange");
438 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
439 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" value="' . $mainport . '">';
440 }
441 }
442 print '</td></tr>';
443
444 // AUTH method
445 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
446 print '<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
447 $vartosmtpstype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING';
448 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
449 // 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)
450 print '<input type="radio" id="radio_pw" name="'.$vartosmtpstype.'" value="LOGIN"'.(getDolGlobalString($vartosmtpstype, 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
451 print '<label for="radio_pw" >'.$langs->trans("UseAUTHLOGIN").'</label>';
452 print '<br>';
453 print '<input type="radio" id="radio_plain" name="'.$vartosmtpstype.'" value="PLAIN"'.(getDolGlobalString($vartosmtpstype, 'PLAIN') == 'PLAIN' ? ' checked' : '').'> ';
454 print '<label for="radio_plain" >'.$langs->trans("UseAUTHPLAIN").'</label>';
455 print '<br>';
456 print '<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.'" value="XOAUTH2"'.(getDolGlobalString($vartosmtpstype) == 'XOAUTH2' ? ' checked' : '').(isModEnabled('oauth') ? '' : ' disabled').'> ';
457 print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
458 if (!isModEnabled('oauth')) {
459 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword=oauth">'.$langs->trans("EnableModuleX", "OAuth").'</a>';
460 } else {
461 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/oauth.php">'.$langs->trans("SetupModuleX", " OAuth").'</a>';
462 }
463 } else {
464 $value = getDolGlobalString($vartosmtpstype, 'LOGIN');
465 $htmltext = $langs->trans("ContactSuperAdminForChange");
466 print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
467 print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING" value="'.$value.'">';
468 }
469 print '</td></tr>';
470 }
471
472 // ID
473 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
474 $mainstmpid = getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING');
475 print '<tr class="drag drop oddeven hideifdefault"><td>' . $langs->trans("MAIN_MAIL_SMTPS_ID") . '</td><td>';
476 // SuperAdministrator access only
477 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
478 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID_EMAILING" size="32" value="' . $mainstmpid . '">';
479 } else {
480 $htmltext = $langs->trans("ContactSuperAdminForChange");
481 print $form->textwithpicto(getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING'), $htmltext, 1, 'superadmin');
482 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID_EMAILING" value="' . $mainstmpid . '">';
483 }
484 print '</td></tr>';
485 }
486
487 // PW
488 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
489 $mainsmtppw = getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING');
490 print '<tr class="drag drop oddeven smtp_pw hideifdefault"><td>' . $langs->trans("MAIN_MAIL_SMTPS_PW") . '</td><td>';
491 // SuperAdministrator access only
492 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
493 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_EMAILING" size="32" value="' . $mainsmtppw . '">';
494 } else {
495 $htmltext = $langs->trans("ContactSuperAdminForChange");
496 print $form->textwithpicto(getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING'), $htmltext, 1, 'superadmin');
497 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW_EMAILING" value="' . $mainsmtppw . '">';
498 }
499 print '</td></tr>';
500 }
501
502 // OAUTH service provider
503 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
504 print '<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
505
506 // SuperAdministrator access only
507 if (!isModEnabled('multicompany') || (/* $user->admin && */ !$user->entity)) {
508 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
509 print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING'));
510 } else {
511 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING')];
512 if (empty($text)) {
513 $text = $langs->trans("Undefined");
514 }
515 $htmltext = $langs->trans("ContactSuperAdminForChange");
516 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
517 print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING" value="' . getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING').'">';
518 }
519 print '</td></tr>';
520 }
521
522
523 // TLS
524 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
525 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
526 if (function_exists('openssl_open')) {
527 print $form->selectyesno('MAIN_MAIL_EMAIL_TLS_EMAILING', (getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING') ? getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING') : 0), 1);
528 } else {
529 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
530 }
531 } else {
532 print yn(0).' ('.$langs->trans("NotSupported").')';
533 }
534 print '</td></tr>';
535
536 // STARTTLS
537 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
538 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
539 if (function_exists('openssl_open')) {
540 print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS_EMAILING', (getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING') ? getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING') : 0), 1);
541 } else {
542 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
543 }
544 } else {
545 print yn(0).' ('.$langs->trans("NotSupported").')';
546 }
547 print '</td></tr>';
548
549 // SMTP_ALLOW_SELF_SIGNED_EMAILING
550 print '<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
551 if (!empty($conf->use_javascript_ajax) || in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
552 if (function_exists('openssl_open')) {
553 print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING') ? getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING') : 0), 1);
554 } else {
555 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
556 }
557 } else {
558 print yn(0).' ('.$langs->trans("NotSupported").')';
559 }
560 print '</td></tr>';
561
562 print '</table>';
563
564 print dol_get_fiche_end();
565
566 print $form->buttonsSaveCancel();
567
568 print '</form>';
569} else {
570 print dol_get_fiche_head($head, 'common_emailing', '', -1);
571
572 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
573 print "<br><br>\n";
574
575 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
576 print '<table class="noborder centpercent">';
577 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
578
579 // Method
580 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
581 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')];
582 if (empty($text)) {
583 $text = $langs->trans("Undefined").img_warning();
584 }
585 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'default') {
586 print '<span class="opacitymedium">'.$text.'</span>';
587 } else {
588 print $text;
589 }
590 print '</td></tr>';
591
592 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
593 // Host server
594 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail')) {
595 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
596 } else {
597 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_EMAILING').'</td></tr>';
598 }
599
600 // Port
601 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail')) {
602 //print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
603 } else {
604 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_EMAILING').'</td></tr>';
605 }
606
607 // AUTH method
608 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
609 $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN');
610 $text = '';
611 if ($authtype === "LOGIN") {
612 $text = $langs->trans("UseAUTHLOGIN");
613 } elseif ($authtype === "PLAIN") {
614 $text = $langs->trans("UseAUTHPLAIN");
615 } elseif ($authtype === "XOAUTH2") {
616 $text = $langs->trans("UseOauth");
617 }
618 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
619 }
620
621 // SMTPS ID
622 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
623 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING').'</td></tr>';
624 }
625
626 // SMTPS PW
627 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') != "XOAUTH2") {
628 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING')).'</td></tr>';
629 }
630
631 // SMTPS oauth service
632 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') === "XOAUTH2") {
633 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING')];
634 if (empty($text)) {
635 $text = $langs->trans("Undefined").img_warning();
636 }
637 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
638 }
639
640 // TLS
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_TLS").'</td><td>';
645 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
646 if (function_exists('openssl_open')) {
647 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING'));
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 // STARTTLS
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_STARTTLS").'</td><td>';
662 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
663 if (function_exists('openssl_open')) {
664 print yn(getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING'));
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 // SMTP_ALLOW_SELF_SIGNED_EMAILING
675 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
676 // Nothing
677 } else {
678 print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
679 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
680 if (function_exists('openssl_open')) {
681 print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING'));
682 } else {
683 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
684 }
685 } else {
686 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
687 }
688 print '</td></tr>';
689 }
690 }
691
692 print '</table>';
693 print '</div>';
694
695 print dol_get_fiche_end();
696
697
698 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail' && !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA')) {
699 print '<br>';
700 /*
701 // Warning 1
702 if ($linuxlike) {
703 $sendmailoption=ini_get('mail.force_extra_parameters');
704 if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption)) {
705 print info_admin($langs->trans("SendmailOptionNotComplete"));
706 }
707 }*/
708 // Warning 2
709 print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
710 }
711
712
713 // Buttons for actions
714
715 print '<div class="tabsAction">';
716
717 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
718
719 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
720 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail' || !$linuxlike) {
721 if (function_exists('fsockopen') && $port && $server) {
722 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=testconnect">' . $langs->trans("DoTestServerAvailability") . '</a>';
723 }
724 } else {
725 print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans("FeatureNotAvailableOnLinux") . '">' . $langs->trans("DoTestServerAvailability") . '</a>';
726 }
727
728 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=test&amp;mode=init">' . $langs->trans("DoTestSend") . '</a>';
729
730 if (isModEnabled('fckeditor')) {
731 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=testhtml&amp;mode=init">' . $langs->trans("DoTestSendHTML") . '</a>';
732 }
733 }
734
735 print '</div>';
736
737
738 if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) {
739 $text = $langs->trans("WarningPHPMail", $listofmethods['mail'], $listofmethods['smtps']);
740 print info_admin($text);
741 }
742
743 // Run the test to connect
744 if ($action == 'testconnect') {
745 print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
746 print load_fiche_titre($langs->trans("DoTestServerAvailability"));
747
748 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
749 $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext);
750
751 $result = $mail->check_server_port((string) $server, (int) $port);
752 if ($result) {
753 print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'</div>';
754 } else {
755 $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port);
756
757 if ($mail->error) {
758 $errormsg .= ' - '.$mail->error;
759 }
760
761 setEventMessages($errormsg, null, 'errors');
762 }
763 print '<br>';
764 }
765
766 // Show email send test form
767 if ($action == 'test' || $action == 'testhtml') {
768 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
769 print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
770
771 print dol_get_fiche_head(array(), '', '', -1);
772
773 // Cree l'objet formulaire mail
774 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
775 $formmail = new FormMail($db);
776 $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
777 $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
778 $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
779 $formmail->fromid = $user->id;
780 $formmail->fromalsorobot = 1;
781 $formmail->withfromreadonly = 0;
782 $formmail->withsubstit = 0;
783 $formmail->withfrom = 1;
784 $formmail->witherrorsto = 1;
785 $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
786 $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
787 $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
788 $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
789 $formmail->withtopicreadonly = 0;
790 $formmail->withfile = 2;
791 $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
792 $formmail->withbodyreadonly = 0;
793 $formmail->withcancel = 1;
794 $formmail->withdeliveryreceipt = 1;
795 $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
796 $formmail->ckeditortoolbar = 'dolibarr_mailings';
797 // Tableau des substitutions
798 $formmail->substit = $substitutionarrayfortest;
799 // Tableau des parameters complementaires du post
800 $formmail->param["action"] = "send";
801 $formmail->param["models"] = "body";
802 $formmail->param["mailid"] = 0;
803 $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
804
805 // Init list of files
806 if (GETPOST("mode", "aZ09") == 'init') {
807 $formmail->clear_attached_files();
808 }
809
810 print $formmail->get_form('addfile', 'removefile');
811
812 print dol_get_fiche_end();
813 }
814}
815
816// End of page
817llxFooter();
818$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
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").
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.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.