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