dolibarr 19.0.4
mails.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2020 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) 2023 Anthony Berton <anthony.berton@bb2a.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$trackid = GETPOST('trackid');
39
40if (!$user->admin) {
42}
43
44$usersignature = $user->signature;
45// For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html.
46if ($action == 'test' || ($action == 'send' && $trackid == 'test')) {
47 $usersignature = dol_string_nohtmltag($usersignature, 2);
48}
49
50$substitutionarrayfortest = array(
51 '__USER_LOGIN__' => $user->login,
52 '__USER_EMAIL__' => $user->email,
53 '__USER_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
54 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature : ''), // Done into actions_sendmails
55 '__ID__' => 'RecipientID',
56 //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
57 '__LASTNAME__' => 'RecipientLastname',
58 '__FIRSTNAME__' => 'RecipientFirstname',
59 '__ADDRESS__'=> 'RecipientAddress',
60 '__ZIP__'=> 'RecipientZip',
61 '__TOWN_'=> 'RecipientTown',
62 '__COUNTRY__'=> 'RecipientCountry',
63 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
64 '__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" />',
65);
66complete_substitutions_array($substitutionarrayfortest, $langs);
67
68
69
70/*
71 * Actions
72 */
73
74if ($action == 'update' && !$cancel) {
75 if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) {
76 $error++;
77 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors');
78 $action = 'edit';
79 }
80 if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) {
81 $error++;
82 setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors');
83 $action = 'edit';
84 }
85
86 if (!$error) {
87 dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity);
88 dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
89 dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity);
90 dolibarr_set_const($db, 'MAIN_MAIL_NO_WITH_TO_SELECTED', GETPOST('MAIN_MAIL_NO_WITH_TO_SELECTED', 'int'), 'chaine', 0, '', $conf->entity);
91 // Send mode parameters
92 dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity);
93 dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
94 dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
95 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
96 if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
97 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
98 }
99 if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
100 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
101 }
102 if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
103 dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
104 }
105 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
106 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
107 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
108
109 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity);
110 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
111 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
112 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
113 // Content parameters
114 dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
115 dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
116 dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
117 dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
118
119
120 header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
121 exit;
122 }
123}
124
125if ($action == 'disablephpmailwarning' && !$cancel) {
126 dolibarr_set_const($db, 'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1, 'chaine', 1, 0, $conf->entity);
127
128 setEventMessages($langs->trans("WarningDisabled"), null, 'mesgs');
129}
130
131// Actions to send emails
132$id = 0;
133$actiontypecode = ''; // Not an event for agenda
134$triggersendname = ''; // Disable triggers
135$paramname = 'id';
136$mode = 'emailfortest';
137$trackid = ($action == 'send' ? GETPOST('trackid', 'aZ09') : $action);
138$sendcontext = '';
139include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
140
141if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
142 $action = 'test';
143}
144if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
145 $action = 'testhtml';
146}
147
148
149
150/*
151 * View
152 */
153
154$form = new Form($db);
155
156$linuxlike = 1;
157if (preg_match('/^win/i', PHP_OS)) {
158 $linuxlike = 0;
159}
160if (preg_match('/^mac/i', PHP_OS)) {
161 $linuxlike = 0;
162}
163
164if (!getDolGlobalString('MAIN_MAIL_SENDMODE')) {
165 $conf->global->MAIN_MAIL_SENDMODE = 'mail';
166}
167$port = getDolGlobalString('MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');
168if (!$port) {
169 $port = 25;
170}
171$server = getDolGlobalString('MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP');
172if (!$server) {
173 $server = '127.0.0.1';
174}
175
176
177$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
178llxHeader('', $langs->trans("Setup"), $wikihelp);
179
180print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
181
183
184// List of sending methods
185$listofmethods = array();
186$listofmethods['mail'] = 'PHP mail function';
187$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
188if (version_compare(phpversion(), '7.0', '>=')) {
189 $listofmethods['swiftmailer'] = 'Swift Mailer socket library';
190}
191
192// List of oauth services
193$oauthservices = array();
194
195foreach ($conf->global as $key => $val) {
196 if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
197 $key = preg_replace('/^OAUTH_/', '', $key);
198 $key = preg_replace('/_ID$/', '', $key);
199 if (preg_match('/^.*-/', $key)) {
200 $name = preg_replace('/^.*-/', '', $key);
201 } else {
202 $name = $langs->trans("NoName");
203 }
204 $provider = preg_replace('/-.*$/', '', $key);
205 $provider = ucfirst(strtolower($provider));
206
207 $oauthservices[$key] = $name." (".$provider.")";
208 }
209}
210
211if ($action == 'edit') {
212 if ($conf->use_javascript_ajax) {
213 print "\n".'<script type="text/javascript">';
214 print 'jQuery(document).ready(function () {
215 function initfields()
216 {
217 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
218 {
219 console.log("I choose php mail mode");
220 jQuery(".drag").hide();
221 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
222 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
223 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
224 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
225 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
226 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
232 jQuery(".smtp_method").hide();
233 jQuery(".dkim").hide();
234 jQuery(".smtp_auth_method").hide();
235 ';
236 if ($linuxlike) {
237 print '
238 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
239 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
240 jQuery("#smtp_server_mess").show();
241 jQuery("#smtp_port_mess").show();';
242 } else {
243 print '
244 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
245 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
246 jQuery("#smtp_server_mess").hide();
247 jQuery("#smtp_port_mess").hide();';
248 }
249 print '
250 }
251 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
252 {
253 console.log("I choose smtps mode");
254 jQuery(".drag").show();
255 jQuery("#MAIN_MAIL_EMAIL_TLS").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS').');
256 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
257 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS').');
258 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').');
260 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
261 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
262 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
263 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
264 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
265 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
266 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
269 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
270 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
271 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
272 jQuery("#MAIN_MAIL_SMTP_PORT").show();
273 jQuery("#smtp_server_mess").hide();
274 jQuery("#smtp_port_mess").hide();
275 jQuery(".smtp_method").show();
276 jQuery(".dkim").hide();
277 jQuery(".smtp_auth_method").show();
278 }
279 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
280 {
281 console.log("I choose swiftmailer mode");
282 jQuery(".drag").show();
283 jQuery("#MAIN_MAIL_EMAIL_TLS").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS').');
284 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
285 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS').');
286 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').');
288 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
289 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_ENABLED').');
290 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
291 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
292 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
293 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
294 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
295 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
296 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
297 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
298 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
299 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
300 jQuery("#MAIN_MAIL_SMTP_PORT").show();
301 jQuery("#smtp_server_mess").hide();
302 jQuery("#smtp_port_mess").hide();
303 jQuery(".smtp_method").show();
304 jQuery(".dkim").show();
305 jQuery(".smtp_auth_method").show();
306 }
307 }
308 function change_smtp_auth_method() {
309 console.log(jQuery("#radio_pw").prop("checked"));
310 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
311 jQuery(".smtp_oauth_service").show();
312 jQuery(".smtp_pw").hide();
313 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
314 jQuery(".smtp_oauth_service").show();
315 jQuery(".smtp_pw").hide();
316 } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
317 jQuery(".smtp_oauth_service").hide();
318 jQuery(".smtp_pw").hide();
319 } else {
320 jQuery(".smtp_oauth_service").hide();
321 jQuery(".smtp_pw").show();
322 }
323 }
324 initfields();
325 change_smtp_auth_method();
326 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
327 initfields();
328 change_smtp_auth_method();
329 });
330 jQuery("#radio_pw, #radio_oauth").change(function() {
331 change_smtp_auth_method();
332 });
333 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
334 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
335 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
336 else
337 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
338 });
339 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
340 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
341 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
342 else
343 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
344 });
345 })';
346 print '</script>'."\n";
347 }
348
349 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
350 print '<input type="hidden" name="token" value="'.newToken().'">';
351 print '<input type="hidden" name="action" value="update">';
352
353 print dol_get_fiche_head($head, 'common', '', -1);
354
355 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
356 print "<br><br>\n";
357
358
359 clearstatcache();
360
361
362 print '<table class="noborder centpercent">';
363 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
364
365 // Method
366 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
367
368 // SuperAdministrator access only
369 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
370 print $form->selectarray('MAIN_MAIL_SENDMODE', $listofmethods, getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'));
371 } else {
372 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')];
373 if (empty($text)) {
374 $text = $langs->trans("Undefined");
375 }
376 $htmltext = $langs->trans("ContactSuperAdminForChange");
377 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
378 print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail').'">';
379 }
380 print '</td></tr>';
381
382 // Host server
383 print '<tr class="oddeven hideonmodemail">';
384 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
385 print '<td>';
386 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
387 print '</td><td>';
388 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
389 print '</td>';
390 } else {
391 print '<td>';
392 $mainserver = (getDolGlobalString('MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER : '');
393 $smtpserver = ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined");
394 if ($linuxlike) {
395 print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
396 } else {
397 print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
398 }
399 print '</td><td>';
400 // SuperAdministrator access only
401 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
402 print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'" autocomplete="off">';
403 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">';
404 print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
405 print ' <span class="opacitymedium smtp_method">'.$langs->trans("SeeLinkToOnlineDocumentation").'</span>';
406 } else {
407 $text = !empty($mainserver) ? $mainserver : $smtpserver;
408 $htmltext = $langs->trans("ContactSuperAdminForChange");
409 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
410 print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'">';
411 }
412 print '</td>';
413 }
414 print '</tr>';
415
416 // Port
417 print '<tr class="oddeven hideonmodemail"><td>';
418 if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
419 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
420 print '</td><td>';
421 print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
422 } else {
423 $mainport = (getDolGlobalString('MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
424 $smtpport = ini_get('smtp_port') ? ini_get('smtp_port') : $langs->transnoentities("Undefined");
425 if ($linuxlike) {
426 print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
427 } else {
428 print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
429 }
430 print '</td><td>';
431 // SuperAdministrator access only
432 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
433 print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">';
434 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">';
435 print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
436 } else {
437 $text = (!empty($mainport) ? $mainport : $smtpport);
438 $htmltext = $langs->trans("ContactSuperAdminForChange");
439 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
440 print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.'">';
441 }
442 }
443 print '</td></tr>';
444
445 // Auth mode
446 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
447 print '<tr class="oddeven smtp_auth_method"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
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="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
451 print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
452 print '&nbsp; &nbsp; &nbsp;';
453 print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') == 'XOAUTH2' ? ' checked' : '').'> ';
454 print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
455 } else {
456 $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
457 $htmltext = $langs->trans("ContactSuperAdminForChange");
458 print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
459 print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.'">';
460 }
461 print '</td></tr>';
462 }
463
464 // ID
465 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
466 $mainstmpid = (getDolGlobalString('MAIN_MAIL_SMTPS_ID') ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
467 print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
468 // SuperAdministrator access only
469 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
470 print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">';
471 } else {
472 $htmltext = $langs->trans("ContactSuperAdminForChange");
473 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1, 'superadmin');
474 print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.'">';
475 }
476 print '</td></tr>';
477 }
478
479
480 // PW
481 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
482 $mainsmtppw = (getDolGlobalString('MAIN_MAIL_SMTPS_PW') ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
483 print '<tr class="drag drop oddeven smtp_pw"><td>';
484 print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
485 print '</td><td>';
486 // SuperAdministrator access only
487 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
488 print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT, 'UTF-8') . '" autocomplete="off">';
489 } else {
490 $htmltext = $langs->trans("ContactSuperAdminForChange");
491 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1, 'superadmin');
492 print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT, 'UTF-8') . '">';
493 }
494 print '</td></tr>';
495 }
496
497 // OAUTH service provider
498 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
499 print '<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
500
501 // SuperAdministrator access only
502 if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
503 print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
504 } else {
505 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE')];
506 if (empty($text)) {
507 $text = $langs->trans("Undefined");
508 }
509 $htmltext = $langs->trans("ContactSuperAdminForChange");
510 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
511 print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' . getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'">';
512 }
513 print '</td></tr>';
514 }
515
516 // TLS
517 print '<tr class="oddeven hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
518 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
519 if (function_exists('openssl_open')) {
520 print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (getDolGlobalString('MAIN_MAIL_EMAIL_TLS') ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
521 } else {
522 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
523 }
524 } else {
525 print yn(0).' ('.$langs->trans("NotSupported").')';
526 }
527 print '</td></tr>';
528
529 // STARTTLS
530 print '<tr class="oddeven hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
531 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
532 if (function_exists('openssl_open')) {
533 print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
534 } else {
535 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
536 }
537 } else {
538 print yn(0).' ('.$langs->trans("NotSupported").')';
539 }
540 print '</td></tr>';
541
542 // SMTP_ALLOW_SELF_SIGNED
543 print '<tr class="oddeven hideonmodemail"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
544 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
545 if (function_exists('openssl_open')) {
546 print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
547 } else {
548 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
549 }
550 } else {
551 print yn(0).' ('.$langs->trans("NotSupported").')';
552 }
553 print '</td></tr>';
554
555 // DKIM
556 print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
557 if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer')))) {
558 if (function_exists('openssl_open')) {
559 print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_ENABLED') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
560 } else {
561 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
562 }
563 } else {
564 print yn(0).' ('.$langs->trans("NotSupported").')';
565 }
566 print '</td></tr>';
567
568 // DKIM Domain
569 print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
570 print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_DOMAIN') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN : '');
571 print '"></td></tr>';
572
573 // DKIM Selector
574 print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
575 print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_SELECTOR') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR : '');
576 print '"></td></tr>';
577
578 // DKIM PRIVATE KEY
579 print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
580 print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY : '').'</textarea>';
581 print '</td></tr>';
582
583 print '</table>';
584
585
586 print '<br>';
587
588
589 print '<table class="noborder centpercent">';
590 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("ParametersForTestEnvironment").'</td><td>'.$langs->trans("Value").'</td></tr>';
591
592 // Disable
593 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>';
594 print $form->selectyesno('MAIN_DISABLE_ALL_MAILS', getDolGlobalString('MAIN_DISABLE_ALL_MAILS'), 1);
595 print '</td></tr>';
596
597 // Force e-mail recipient
598 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>';
599 print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO') ? $conf->global->MAIN_MAIL_FORCE_SENDTO : '').'" />';
600 print '</td></tr>';
601
602 print '</table>';
603
604
605 print '<br>';
606
607
608 print '<table class="noborder centpercent">';
609 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
610
611 // From
612 $help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
613 print '<tr class="oddeven"><td class="fieldrequired">';
614 print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
615 print ' '.$help;
616 print '</td>';
617 print '<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(getDolGlobalString('MAIN_MAIL_EMAIL_FROM') ? $conf->global->MAIN_MAIL_EMAIL_FROM : '');
618 print '"></td></tr>';
619
620 // Default from type
621 $liste = array();
622 $liste['user'] = $langs->trans('UserEmail');
623 $liste['company'] = $langs->trans('CompanyEmail').' ('.(!getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
624
625 print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td><td>';
626 print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
627 print '</td></tr>';
628
629 // From
630 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
631 print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO') ? $conf->global->MAIN_MAIL_ERRORS_TO : '');
632 print '"></td></tr>';
633
634 // Autocopy to
635 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
636 print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO') ? $conf->global->MAIN_MAIL_AUTOCOPY_TO : '');
637 print '"></td></tr>';
638
639 // Add user to select destinaries list
640 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>';
641 print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
642 print '</td></tr>';
643 //Disable autoselect to
644 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_NO_WITH_TO_SELECTED").'</td><td>';
645 print $form->selectyesno('MAIN_MAIL_NO_WITH_TO_SELECTED', getDolGlobalString('MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
646 print '</td></tr>';
647
648 print '</table>';
649
650 print dol_get_fiche_end();
651
652 print $form->buttonsSaveCancel();
653
654 print '</form>';
655} else {
656 print dol_get_fiche_head($head, 'common', '', -1);
657
658 print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
659 print "<br><br>\n";
660
661 if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
662 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
663 print '<table class="noborder centpercent">';
664 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
665
666 // Method
667 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
668 $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail')];
669 if (empty($text)) {
670 $text = $langs->trans("Undefined").img_warning();
671 }
672 print $text;
673
674 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && !getDolGlobalString('MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP')) {
675 $textwarning = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
676 print $form->textwithpicto('', '<span class="small">'.$textwarning.'</span>', 1, 'warning', 'nomargintop');
677 }
678
679 print '</td></tr>';
680
681 // Host server
682 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
683 //print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
684 } else {
685 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ? ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(getDolGlobalString('MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>';
686 }
687
688
689 // Port
690 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
691 //print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
692 } else {
693 print '<tr class="oddeven"><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') ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>';
694 }
695
696 // AUTH method
697 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
698 $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
699 $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
700 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
701 }
702
703 // SMTPS ID
704 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
705 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>' . getDolGlobalString('MAIN_MAIL_SMTPS_ID').'</td></tr>';
706 }
707
708 // SMTPS PW
709 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
710 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW')).'</td></tr>';
711 }
712
713 // SMTPS oauth service
714 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
715 $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE')];
716 if (empty($text)) {
717 $text = $langs->trans("Undefined").img_warning();
718 }
719 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
720 }
721
722 // TLS
723 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
724 // Nothing
725 } else {
726 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
727 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
728 if (function_exists('openssl_open')) {
729 print yn($conf->global->MAIN_MAIL_EMAIL_TLS);
730 } else {
731 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
732 }
733 } else {
734 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
735 }
736 print '</td></tr>';
737 }
738
739 // STARTTLS
740 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
741 // Nothing
742 } else {
743 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
744 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
745 if (function_exists('openssl_open')) {
746 print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
747 } else {
748 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
749 }
750 } else {
751 //print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
752 }
753 print '</td></tr>';
754 }
755
756 // SMTP_ALLOW_SELF_SIGNED
757 if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
758 // Nothing
759 } else {
760 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
761 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
762 if (function_exists('openssl_open')) {
763 print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
764 } else {
765 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
766 }
767 } else {
768 print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
769 }
770 print '</td></tr>';
771 }
772
773 if (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'swiftmailer') {
774 // DKIM
775 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
776 if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer'))) {
777 if (function_exists('openssl_open')) {
778 print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_DKIM_ENABLED'));
779 } else {
780 print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
781 }
782 } else {
783 print yn(0).' ('.$langs->trans("NotSupported").')';
784 }
785 print '</td></tr>';
786
787 // Domain
788 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
789 print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_DOMAIN');
790 print '</td></tr>';
791
792 // Selector
793 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
794 print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_SELECTOR');
795 print '</td></tr>';
796
797 // PRIVATE KEY
798 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
799 print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
800 print '</td></tr>';
801 }
802
803 print '</table>';
804 print '</div>';
805
806 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && !getDolGlobalString('MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP')) {
807 $messagetoshow = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
808 $messagetoshow .= ' '.$langs->trans("WarningPHPMailDbis", '{s1}', '{s2}');
809 $linktosetvar1 = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=disablephpmailwarning&token='.newToken().'">';
810 $linktosetvar2 = '</a>';
811 $messagetoshow = str_replace('{s1}', $linktosetvar1, $messagetoshow);
812 $messagetoshow = str_replace('{s2}', $linktosetvar2, $messagetoshow);
813
814 print info_admin($messagetoshow, 0, 0, 'warning nomargintop');
815 }
816
817 print '<br>';
818 }
819
820 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
821 print '<table class="noborder centpercent">';
822 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("ParametersForTestEnvironment").'</td><td>'.$langs->trans("Value").'</td></tr>';
823
824 // Disable
825 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn(getDolGlobalString('MAIN_DISABLE_ALL_MAILS'));
826 if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
827 print img_warning($langs->trans("Disabled"));
828 }
829 print '</td></tr>';
830
831 if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
832 // Force e-mail recipient
833 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
834 if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
835 if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
836 print img_warning($langs->trans("ErrorBadEMail"));
837 } else {
838 print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
839 }
840 }
841 print '</td></tr>';
842 }
843
844 print '</table>';
845 print '</div>';
846
847
848 print '<br>';
849
850
851 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
852 print '<table class="noborder centpercent">';
853 print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
854
855 // From
856 $help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
857 print '<tr class="oddeven"><td>';
858 print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
859 print ' '.$help;
860 print '</td>';
861 print '<td>' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
862 if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM')) {
863 print img_warning($langs->trans("Mandatory"));
864 } elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
865 print img_warning($langs->trans("ErrorBadEMail"));
866 }
867 print '</td></tr>';
868
869 // Default from type
870 $liste = array();
871 $liste['user'] = $langs->trans('UserEmail');
872 $liste['company'] = $langs->trans('CompanyEmail').' ('.(!getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
873 $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
874 $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
875 $resql = $db->query($sql);
876 if ($resql) {
877 $num = $db->num_rows($resql);
878 $i = 0;
879 while ($i < $num) {
880 $obj = $db->fetch_object($resql);
881 if ($obj) {
882 $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
883 }
884 $i++;
885 }
886 } else {
887 dol_print_error($db);
888 }
889
890 print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
891 print '<td>';
892 if (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'robot') {
893 print $langs->trans('RobotEmail');
894 } elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'user') {
895 print $langs->trans('UserEmail');
896 } elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') {
897 print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
898 } else {
899 $id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'));
900 if ($id > 0) {
901 include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
902 $emailsenderprofile = new EmailSenderProfile($db);
903 $emailsenderprofile->fetch($id);
904 print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>');
905 }
906 }
907 print '</td></tr>';
908
909 // Errors To
910 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
911 print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
912 if (getDolGlobalString('MAIN_MAIL_ERRORS_TO') && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
913 print img_warning($langs->trans("ErrorBadEMail"));
914 }
915 print '</td></tr>';
916
917 // Autocopy to
918 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
919 print '<td>';
920 if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO')) {
921 $listofemail = explode(',', getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'));
922 $i = 0;
923 foreach ($listofemail as $key => $val) {
924 if ($i) {
925 print ', ';
926 }
927 $val = trim($val);
928 print $val;
929 if (!isValidEmail($val, 0, 1)) {
930 print img_warning($langs->trans("ErrorBadEMail", $val));
931 }
932 $i++;
933 }
934 } else {
935 print '&nbsp;';
936 }
937 print '</td></tr>';
938
939 //Add user to select destinaries list
940 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>'.yn(getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')).'</td></tr>';
941 //Disable autoselect to
942 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_NO_WITH_TO_SELECTED").'</td><td>'.yn(getDolGlobalString('MAIN_MAIL_NO_WITH_TO_SELECTED')).'</td></tr>';
943
944 print '</table>';
945 print '</div>';
946
947
948 print dol_get_fiche_end();
949
950
951 // Actions button
952 print '<div class="tabsAction">';
953
954 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
955
956 if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
957 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') != 'mail' || !$linuxlike) {
958 if (function_exists('fsockopen') && $port && $server) {
959 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
960 }
961 } else {
962 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
963 }
964
965 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>';
966
967 if (isModEnabled('fckeditor')) {
968 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>';
969 }
970 }
971
972 print '</div>';
973
974
975 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA')) {
976 /*
977 // Warning 1
978 if ($linuxlike)
979 {
980 $sendmailoption=ini_get('mail.force_extra_parameters');
981 if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
982 {
983 print info_admin($langs->trans("SendmailOptionNotComplete"));
984 }
985 }*/
986 // Warning 2
987 print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
988 }
989
990 if (!in_array($action, array('testconnect', 'test', 'testhtml'))) {
991 $text = '';
992 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
993 //$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
994 }
995
996 if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
997 if (getDolGlobalString('MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD')) {
998 // List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com'
999 $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
1000 } else {
1001 // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'.
1002 if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) {
1003 // List of IP show as record to add in SPF if we use the mail method
1004 $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
1005 }
1006 }
1007 } else {
1008 if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) {
1009 // List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]'
1010 // TODO Add a key to allow to show the IP/name of server detected dynamically
1011 $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
1012 }
1013 if (getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD')) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server.
1014 // List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com'
1015 $text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
1016 }
1017 }
1018 // Test SPF email company
1019 $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL');
1020 $dnsinfo = false;
1021 if (!empty($companyemail) && function_exists('dns_get_record') && !getDolGlobalString('MAIN_DISABLE_DNS_GET_RECORD')) {
1022 $arrayofemailparts = explode('@', $companyemail);
1023 if (count($arrayofemailparts) == 2) {
1024 $domain = $arrayofemailparts[1];
1025 $dnsinfo = dns_get_record($domain, DNS_TXT);
1026 }
1027 }
1028 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1029 foreach ($dnsinfo as $info) {
1030 if (strpos($info['txt'], 'v=spf') !== false) {
1031 $text .= ($text ? '<br><br>' : '').$langs->trans("ActualMailSPFRecordFound", $companyemail, $info['txt']);
1032 }
1033 }
1034 }
1035 // Test SPF default automatic email from
1036 $defaultnoreplyemail = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
1037 if ($defaultnoreplyemail != $companyemail) { // We show if email differs
1038 $dnsinfo = false;
1039 if (!empty($defaultnoreplyemail) && function_exists('dns_get_record') && !getDolGlobalString('MAIN_DISABLE_DNS_GET_RECORD')) {
1040 $arrayofemailparts = explode('@', $defaultnoreplyemail);
1041 if (count($arrayofemailparts) == 2) {
1042 $domain = $arrayofemailparts[1];
1043 $dnsinfo = dns_get_record($domain, DNS_TXT);
1044 }
1045 }
1046 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1047 foreach ($dnsinfo as $info) {
1048 if (strpos($info['txt'], 'v=spf') !== false) {
1049 $text .= ($text ? '<br><br>' : '').$langs->trans("ActualMailSPFRecordFound", $defaultnoreplyemail, $info['txt']);
1050 }
1051 }
1052 }
1053 }
1054
1055
1056 if ($text) {
1057 print info_admin($text);
1058 }
1059 }
1060
1061 // Run the test to connect
1062 if ($action == 'testconnect') {
1063 print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1064 print load_fiche_titre($langs->trans("DoTestServerAvailability"));
1065
1066 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
1067 $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
1068 $result = $mail->check_server_port($server, $port);
1069 if ($result) {
1070 print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
1071 } else {
1072 $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
1073
1074 if ($mail->error) {
1075 $errormsg .= ' - '.$mail->error;
1076 }
1077
1078 setEventMessages($errormsg, null, 'errors');
1079 }
1080 print '<br>';
1081 }
1082
1083 // Show email send test form
1084 if ($action == 'test' || $action == 'testhtml') {
1085 print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1086 print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
1087
1088 print dol_get_fiche_head(array(), '', '', -1);
1089
1090 // Cree l'objet formulaire mail
1091 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1092 $formmail = new FormMail($db);
1093 $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
1094 $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1095 $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1096 $formmail->fromid = $user->id;
1097 $formmail->fromalsorobot = 1;
1098 $formmail->fromtype = (GETPOSTISSET('fromtype') ? GETPOST('fromtype', 'aZ09') : (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
1099 $formmail->withfromreadonly = 1;
1100 $formmail->withsubstit = 1;
1101 $formmail->withfrom = 1;
1102 $formmail->witherrorsto = 1;
1103 $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
1104 $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
1105 $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
1106 $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
1107 $formmail->withtopicreadonly = 0;
1108 $formmail->withfile = 2;
1109 $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
1110 $formmail->withbodyreadonly = 0;
1111 $formmail->withcancel = 1;
1112 $formmail->withdeliveryreceipt = 1;
1113 $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
1114 $formmail->ckeditortoolbar = 'dolibarr_mailings';
1115 // Tableau des substitutions
1116 $formmail->substit = $substitutionarrayfortest;
1117 // Tableau des parametres complementaires du post
1118 $formmail->param["action"] = "send";
1119 $formmail->param["models"] = "body";
1120 $formmail->param["mailid"] = 0;
1121 $formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
1122
1123 // Init list of files
1124 if (GETPOST("mode", "aZ09") == 'init') {
1125 $formmail->clear_attached_files();
1126 }
1127
1128 print $formmail->get_form('addfile', 'removefile');
1129
1130 print dol_get_fiche_end();
1131
1132 // References
1133 print '<br><br>';
1134 print '<span class="opacitymedium">'.$langs->trans("EMailsWillHaveMessageID").': ';
1135 print dol_escape_htmltag('<timestamp.*@'.dol_getprefix('email').'>');
1136 print '</span>';
1137 }
1138}
1139
1140// End of page
1141llxFooter();
1142$db->close();
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 informations.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class for EmailSenderProfile.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.