29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42$langs->loadLangs(array(
'companies',
'products',
'admin',
'mails',
'other',
'errors'));
44$action =
GETPOST(
'action',
'aZ09');
45$cancel =
GETPOST(
'cancel',
'alpha');
47$usersignature = $user->signature;
49if ($action ==
'test' || $action ==
'send') {
53$substitutionarrayfortest = array(
54 '__ID__' =>
'TESTIdRecord',
55 '__USER_LOGIN__' => $user->login,
56 '__USER_EMAIL__' => $user->email,
57 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
58 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
59 '__LASTNAME__' =>
'RecipientLastname',
60 '__FIRSTNAME__' =>
'RecipientFirstname',
61 '__ADDRESS__' =>
'RecipientAddress',
62 '__ZIP__' =>
'RecipientZip',
63 '__TOWN_' =>
'RecipientTown',
64 '__COUNTRY__' =>
'RecipientCountry',
65 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
70$listofmethods = array();
71$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
72$listofmethods[
'mail'] =
'PHP mail function';
74$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
75if (version_compare(phpversion(),
'7.0',
'>=')) {
76 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
89if ($action ==
'update' && !$cancel) {
91 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_TICKET",
GETPOST(
"MAIN_MAIL_SENDMODE_TICKET"),
'chaine', 0,
'', $conf->entity);
92 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_PORT_TICKET"),
'chaine', 0,
'', $conf->entity);
93 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_TICKET"),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_ID_TICKET"),
'chaine', 0,
'', $conf->entity);
95 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_TICKET")) {
96 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_TICKET",
'password'),
'chaine', 0,
'', $conf->entity);
98 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
99 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
101 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
102 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
104 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_TICKET"),
'chaine', 0,
'', $conf->entity);
105 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_TICKET"),
'chaine', 0,
'', $conf->entity);
106 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);
108 include_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
110 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
118$triggersendname =
'';
120$mode =
'emailfortest';
121$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
122$sendcontext =
'ticket';
123include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
125if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
128if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
129 $action =
'testhtml';
139$form =
new Form($db);
142if (preg_match(
'/^win/i', PHP_OS)) {
145if (preg_match(
'/^mac/i', PHP_OS)) {
150 $conf->global->MAIN_MAIL_SENDMODE_TICKET =
'default';
152$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT_TICKET', (
int) ini_get(
'smtp_port'));
158 $server =
'127.0.0.1';
162$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
163llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_ticket');
170$oauthservices = array();
172foreach ($conf->global as $key => $val) {
173 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
174 $key = preg_replace(
'/^OAUTH_/',
'', $key);
175 $key = preg_replace(
'/_ID$/',
'', $key);
176 if (preg_match(
'/^.*-/', $key)) {
177 $name = preg_replace(
'/^.*-/',
'', $key);
179 $name = $langs->trans(
"NoName");
181 $provider = preg_replace(
'/-.*$/',
'', $key);
182 $provider = ucfirst(strtolower($provider));
184 $oauthservices[$key] = $name.
" (".$provider.
")";
189if ($action ==
'edit') {
190 if ($conf->use_javascript_ajax) {
191 print
"\n".
'<script type="text/javascript">';
192 print
'jQuery(document).ready(function () {
193 function initfields()
195 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
197 jQuery(".hideifdefault").hide();
201 jQuery(".hideifdefault").show();
204 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
206 console.log("I choose php mail mode");
207 jQuery(".drag").hide();
208 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
209 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
210 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
211 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
212 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(0);
213 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").prop("disabled", true);
214 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
215 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
216 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
217 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
218 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
219 jQuery(".smtp_method").hide();
220 jQuery(".dkim").hide();
221 jQuery(".smtp_auth_method").hide();
225 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
226 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
227 jQuery("#smtp_server_mess").show();
228 jQuery("#smtp_port_mess").show();
232 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
233 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
234 jQuery("#smtp_server_mess").hide();
235 jQuery("#smtp_port_mess").hide();
240 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
242 console.log("I choose smtps mail mode");
243 jQuery(".drag").show();
244 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
245 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
246 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
247 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
248 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').
');
249 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
250 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
255 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
256 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
257 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
258 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
260 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
261 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
262 jQuery("#smtp_server_mess").hide();
263 jQuery("#smtp_port_mess").hide();
264 jQuery(".smtp_method").show();
265 jQuery(".dkim").hide();
266 jQuery(".smtp_auth_method").show();
268 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
270 console.log("I choose swiftmailer mail mode");
271 jQuery(".drag").show();
272 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
273 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
274 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
275 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET').
');
277 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET").removeAttr("disabled");
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").val(0);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_TICKET").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").prop("disabled", true);
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").prop("disabled", true);
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").prop("disabled", true);
283 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_TICKET").hide();
284 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_TICKET").hide();
285 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_TICKET").hide();
286 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
288 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
289 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
290 jQuery("#smtp_server_mess").hide();
291 jQuery("#smtp_port_mess").hide();
292 jQuery(".smtp_method").show();
293 jQuery(".dkim").show();
294 jQuery(".smtp_auth_method").show();
297 function change_smtp_auth_method() {
298 console.log("Call smtp auth method "+jQuery("#MAIN_MAIL_SENDMODE_TICKET").val());
299 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\') {
300 if (jQuery("#radio_oauth").prop("checked")) {
301 jQuery(".smtp_pw").hide();
302 jQuery(".smtp_oauth_service").show();
304 jQuery(".smtp_pw").show();
305 jQuery(".smtp_oauth_service").hide();
307 } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\') {
308 if (jQuery("#radio_oauth").prop("checked")) {
309 jQuery(".smtp_pw").hide();
310 jQuery(".smtp_oauth_service").show();
312 jQuery(".smtp_pw").show();
313 jQuery(".smtp_oauth_service").hide();
316 jQuery(".smtp_pw").hide();
317 jQuery(".smtp_oauth_service").hide();
322 change_smtp_auth_method();
324 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
326 change_smtp_auth_method();
328 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
329 change_smtp_auth_method();
331 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
332 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
333 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
335 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
336 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
337 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
340 print
'</script>'.
"\n";
343 print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
344 print
'<input type="hidden" name="token" value="'.newToken().
'">';
345 print
'<input type="hidden" name="action" value="update">';
349 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
355 print
'<table class="noborder centpercent">';
356 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
360 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
363 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
364 print $form->selectarray(
'MAIN_MAIL_SENDMODE_TICKET', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'));
368 $text = $langs->trans(
"Undefined");
370 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
371 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
372 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET').
'">';
378 print
'<tr class="oddeven hideifdefault">';
379 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
381 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
383 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
388 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
390 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
392 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
396 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
397 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.
'">';
398 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.
'">';
399 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
400 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
402 $text = !empty($mainserver) ? $mainserver : $smtpserver;
403 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
404 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
405 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.
'">';
413 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
414 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
415 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
417 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
420 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
422 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
424 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
428 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
429 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.
'">';
430 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.
'">';
431 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
433 $text = (!empty($mainport) ? $mainport : $smtpport);
434 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
435 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
436 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.
'">';
442 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
443 print
'<tr class="oddeven smtp_auth_method hideonmodemail hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
444 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET';
445 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
447 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
448 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
450 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
451 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
453 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(
isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
454 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
456 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
458 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
462 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
463 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
464 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.
'">';
470 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
472 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
474 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
475 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
477 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
478 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET'), $htmltext, 1,
'superadmin');
479 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
485 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
487 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
489 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
490 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
492 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
493 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET'), $htmltext, 1,
'superadmin');
494 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
500 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
501 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
503 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
504 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET'));
508 $text = $langs->trans(
"Undefined");
510 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
511 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
512 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').
'">';
518 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
519 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
520 if (function_exists(
'openssl_open')) {
523 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
526 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
531 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
532 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
533 if (function_exists(
'openssl_open')) {
534 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET') : 0), 1);
536 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
539 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
544 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
545 if (!empty($conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
546 if (function_exists(
'openssl_open')) {
547 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') : 0), 1);
549 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
552 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
560 print $form->buttonsSaveCancel();
566 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
569 print
'<div class="div-table-responsive-no-min">';
570 print
'<table class="noborder centpercent">';
571 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
574 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
577 $text = $langs->trans(
"Undefined").img_warning();
580 print
'<span class="opacitymedium">'.$text.
'</span>';
591 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').
'</td></tr>';
598 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').
'</td></tr>';
602 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
605 if ($authtype ===
"LOGIN") {
606 $text = $langs->trans(
"UseAUTHLOGIN");
607 } elseif ($authtype ===
"PLAIN") {
608 $text = $langs->trans(
"UseAUTHPLAIN");
609 } elseif ($authtype ===
"XOAUTH2") {
610 $text = $langs->trans(
"UseOauth");
612 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
616 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
617 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET').
'</td></tr>';
622 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET')).
'</td></tr>';
629 $text = $langs->trans(
"Undefined").img_warning();
631 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
638 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
639 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
640 if (function_exists(
'openssl_open')) {
643 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
646 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
655 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
656 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
657 if (function_exists(
'openssl_open')) {
660 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
663 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
672 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
673 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
674 if (function_exists(
'openssl_open')) {
677 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
680 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
705 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
711 print
'<div class="tabsAction">';
713 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
717 if (function_exists(
'fsockopen') && $port && $server) {
718 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
721 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
724 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
727 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
734 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
735 $text = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']);
740 if ($action ==
'testconnect') {
741 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
744 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
745 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
747 $result = $mail->check_server_port((
string) $server, (
int) $port);
749 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", (
string) $server, (
string) $port).
'</div>';
751 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", (
string) $server, (
string) $port);
754 $errormsg .=
' - '.$mail->error;
763 if ($action ==
'test' || $action ==
'testhtml') {
764 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
765 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
770 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
772 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
773 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
774 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
775 $formmail->fromid = $user->id;
776 $formmail->fromalsorobot = 1;
777 $formmail->withfromreadonly = 0;
778 $formmail->withsubstit = 0;
779 $formmail->withfrom = 1;
780 $formmail->witherrorsto = 1;
781 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
782 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
783 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
784 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
785 $formmail->withtopicreadonly = 0;
786 $formmail->withfile = 2;
787 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
788 $formmail->withbodyreadonly = 0;
789 $formmail->withcancel = 1;
790 $formmail->withdeliveryreceipt = 1;
791 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
792 $formmail->ckeditortoolbar =
'dolibarr_mailings';
794 $formmail->substit = $substitutionarrayfortest;
796 $formmail->param[
"action"] =
"send";
797 $formmail->param[
"models"] =
"body";
798 $formmail->param[
"mailid"] = 0;
799 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
802 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
803 $formmail->clear_attached_files();
806 print $formmail->get_form(
'addfile',
'removefile');
$id
Support class for third parties, contacts, members, users or resources.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
email_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.