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