27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32$langs->loadLangs(array(
'companies',
'products',
'admin',
'mails',
'other',
'errors'));
34$action =
GETPOST(
'action',
'aZ09');
35$cancel =
GETPOST(
'cancel',
'aZ09');
37$usersignature = $user->signature;
39if ($action ==
'test' || $action ==
'send') {
43$substitutionarrayfortest = array(
44 '__ID__' =>
'TESTIdRecord',
45 '__USER_LOGIN__' => $user->login,
46 '__USER_EMAIL__' => $user->email,
47 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
48 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
49 '__LASTNAME__' =>
'RecipientLastname',
50 '__FIRSTNAME__' =>
'RecipientFirstname',
51 '__ADDRESS__'=>
'RecipientAddress',
52 '__ZIP__'=>
'RecipientZip',
53 '__TOWN_'=>
'RecipientTown',
54 '__COUNTRY__'=>
'RecipientCountry',
55 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
60$listofmethods = array();
61$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
62$listofmethods[
'mail'] =
'PHP mail function';
64$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
65if (version_compare(phpversion(),
'7.0',
'>=')) {
66 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
79if ($action ==
'update' && !$cancel) {
81 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_TICKET",
GETPOST(
"MAIN_MAIL_SENDMODE_TICKET"),
'chaine', 0,
'', $conf->entity);
82 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_PORT_TICKET"),
'chaine', 0,
'', $conf->entity);
83 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_TICKET"),
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_ID_TICKET"),
'chaine', 0,
'', $conf->entity);
85 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_TICKET")) {
86 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_TICKET",
'none'),
'chaine', 0,
'', $conf->entity);
88 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
89 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
91 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
92 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_TICKET"),
'chaine', 0,
'', $conf->entity);
95 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_TICKET"),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET"),
'chaine', 0,
'', $conf->entity);
98 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
106$triggersendname =
'';
108$mode =
'emailfortest';
109$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
110$sendcontext =
'ticket';
111include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
113if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
116if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
117 $action =
'testhtml';
127$form =
new Form($db);
130if (preg_match(
'/^win/i', PHP_OS)) {
133if (preg_match(
'/^mac/i', PHP_OS)) {
138 $conf->global->MAIN_MAIL_SENDMODE_TICKET =
'default';
140$port =
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get(
'smtp_port');
144$server =
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get(
'SMTP');
146 $server =
'127.0.0.1';
150$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
151llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_ticket');
158$oauthservices = array();
160foreach ($conf->global as $key => $val) {
161 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
162 $key = preg_replace(
'/^OAUTH_/',
'', $key);
163 $key = preg_replace(
'/_ID$/',
'', $key);
164 if (preg_match(
'/^.*-/', $key)) {
165 $name = preg_replace(
'/^.*-/',
'', $key);
167 $name = $langs->trans(
"NoName");
169 $provider = preg_replace(
'/-.*$/',
'', $key);
170 $provider = ucfirst(strtolower($provider));
172 $oauthservices[$key] = $name.
" (".$provider.
")";
177if ($action ==
'edit') {
178 if ($conf->use_javascript_ajax) {
179 print
"\n".
'<script type="text/javascript">';
180 print
'jQuery(document).ready(function () {
181 function initfields()
183 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
185 jQuery(".hideifdefault").hide();
189 jQuery(".hideifdefault").show();
192 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
194 console.log("I choose php mail mode");
195 jQuery(".drag").hide();
196 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
197 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
198 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
199 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
200 jQuery(".smtp_method").hide();
201 jQuery(".smtp_auth_method").hide();
205 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
206 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
207 jQuery("#smtp_server_mess").show();
208 jQuery("#smtp_port_mess").show();
212 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
213 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
214 jQuery("#smtp_server_mess").hide();
215 jQuery("#smtp_port_mess").hide();
220 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
222 console.log("I choose smtps mail mode");
223 jQuery(".drag").show();
224 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
225 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
226 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
227 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
228 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
229 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
230 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
231 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
232 jQuery("#smtp_server_mess").hide();
233 jQuery("#smtp_port_mess").hide();
234 jQuery(".smtp_method").show();
235 jQuery(".smtp_auth_method").show();
237 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
239 console.log("I choose swiftmailer mail mode");
240 jQuery(".drag").show();
241 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
242 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
243 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
244 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
245 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
248 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
249 jQuery("#smtp_server_mess").hide();
250 jQuery("#smtp_port_mess").hide();
251 jQuery(".smtp_method").show();
252 jQuery(".smtp_auth_method").show();
255 function change_smtp_auth_method() {
256 console.log("Call smtp auth method");
257 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
258 jQuery(".smtp_pw").hide();
259 jQuery(".smtp_oauth_service").show();
260 } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
261 jQuery(".smtp_pw").hide();
262 jQuery(".smtp_oauth_service").show();
263 } else if(jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\'){
264 jQuery(".smtp_pw").hide();
265 jQuery(".smtp_oauth_service").hide();
267 jQuery(".smtp_pw").show();
268 jQuery(".smtp_oauth_service").hide();
273 change_smtp_auth_method();
275 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
277 change_smtp_auth_method();
279 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
280 change_smtp_auth_method();
282 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
283 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
284 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
286 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
287 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
288 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
291 print
'</script>'.
"\n";
294 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
295 print
'<input type="hidden" name="token" value="'.newToken().
'">';
296 print
'<input type="hidden" name="action" value="update">';
300 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
306 print
'<table class="noborder centpercent">';
307 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
311 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
314 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
315 print $form->selectarray(
'MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
319 $text = $langs->trans(
"Undefined");
321 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
322 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
323 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET').
'">';
329 print
'<tr class="oddeven hideifdefault">';
330 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
332 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
334 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
338 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'');
339 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
341 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
343 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
347 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
348 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.
'">';
349 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.
'">';
350 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
351 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
353 $text = !empty($mainserver) ? $mainserver : $smtpserver;
354 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
355 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
356 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.
'">';
364 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
365 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
366 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
368 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
370 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'');
371 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
373 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
375 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
379 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
380 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.
'">';
381 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.
'">';
382 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
384 $text = (!empty($mainport) ? $mainport : $smtpport);
385 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
386 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
387 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.
'">';
393 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
394 print
'<tr class="oddeven smtp_auth_method hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
395 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET';
396 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
398 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
399 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
401 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
402 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
404 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
405 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
406 if (!isModEnabled(
'oauth')) {
407 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
409 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
413 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
414 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
415 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.
'">';
421 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
422 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET :
'');
423 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
425 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
426 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
428 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
429 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1,
'superadmin');
430 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
436 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
437 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET :
'');
438 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
440 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
441 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
443 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
444 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1,
'superadmin');
445 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
451 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
452 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
454 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
455 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
459 $text = $langs->trans(
"Undefined");
461 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
462 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
463 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').
'">';
470 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
471 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
472 if (function_exists(
'openssl_open')) {
473 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
475 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
478 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
484 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
485 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
486 if (function_exists(
'openssl_open')) {
487 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
489 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
492 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
497 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
498 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
499 if (function_exists(
'openssl_open')) {
500 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET : 0), 1);
502 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
505 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
513 print $form->buttonsSaveCancel();
519 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
522 print
'<div class="div-table-responsive-no-min">';
523 print
'<table class="noborder centpercent">';
524 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
527 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
530 $text = $langs->trans(
"Undefined").img_warning();
533 print
'<span class="opacitymedium">'.$text.
'</span>';
544 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'').
'</td></tr>';
551 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT", ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'').
'</td></tr>';
555 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
558 if ($authtype ===
"LOGIN") {
559 $text = $langs->trans(
"UseAUTHLOGIN");
560 } elseif ($authtype ===
"PLAIN") {
561 $text = $langs->trans(
"UseAUTHPLAIN");
562 } elseif ($authtype ===
"XOAUTH2") {
563 $text = $langs->trans(
"UseOauth");
565 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
569 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
570 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET').
'</td></tr>';
574 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') !=
"XOAUTH2") {
575 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET')).
'</td></tr>';
582 $text = $langs->trans(
"Undefined").img_warning();
584 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").
'</td><td>'.$text.
'</td></tr>';
591 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
592 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
593 if (function_exists(
'openssl_open')) {
596 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
599 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
608 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
609 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
610 if (function_exists(
'openssl_open')) {
613 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
616 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
625 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
626 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
627 if (function_exists(
'openssl_open')) {
630 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
633 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
658 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
664 print
'<div class="tabsAction">';
666 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
670 if (function_exists(
'fsockopen') && $port && $server) {
671 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
674 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
677 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
679 if (isModEnabled(
'fckeditor')) {
680 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
687 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
688 $text = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']);
693 if ($action ==
'testconnect') {
694 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
697 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
698 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
700 $result = $mail->check_server_port($server, $port);
702 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
704 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
707 $errormsg .=
' - '.$mail->error;
716 if ($action ==
'test' || $action ==
'testhtml') {
717 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
718 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
723 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
725 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
726 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
727 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
728 $formmail->fromid = $user->id;
729 $formmail->fromalsorobot = 1;
730 $formmail->withfromreadonly = 0;
731 $formmail->withsubstit = 0;
732 $formmail->withfrom = 1;
733 $formmail->witherrorsto = 1;
734 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
735 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
736 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
737 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
738 $formmail->withtopicreadonly = 0;
739 $formmail->withfile = 2;
740 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
741 $formmail->withbodyreadonly = 0;
742 $formmail->withcancel = 1;
743 $formmail->withdeliveryreceipt = 1;
744 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
745 $formmail->ckeditortoolbar =
'dolibarr_mailings';
747 $formmail->substit = $substitutionarrayfortest;
749 $formmail->param[
"action"] =
"send";
750 $formmail->param[
"models"] =
"body";
751 $formmail->param[
"mailid"] = 0;
752 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
755 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
756 $formmail->clear_attached_files();
759 print $formmail->get_form(
'addfile',
'removefile');
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.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.