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",
'chaine'),
'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",
'chaine'),
'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);
97 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
105$triggersendname =
'';
107$mode =
'emailfortest';
108$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
109$sendcontext =
'ticket';
110include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
112if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
115if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
116 $action =
'testhtml';
126$form =
new Form($db);
129if (preg_match(
'/^win/i', PHP_OS)) {
132if (preg_match(
'/^mac/i', PHP_OS)) {
137 $conf->global->MAIN_MAIL_SENDMODE_TICKET =
'default';
139$port =
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get(
'smtp_port');
143$server =
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get(
'SMTP');
145 $server =
'127.0.0.1';
149$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
150llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
157$oauthservices = array();
159foreach ($conf->global as $key => $val) {
160 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
161 $key = preg_replace(
'/^OAUTH_/',
'', $key);
162 $key = preg_replace(
'/_ID$/',
'', $key);
163 if (preg_match(
'/^.*-/', $key)) {
164 $name = preg_replace(
'/^.*-/',
'', $key);
166 $name = $langs->trans(
"NoName");
168 $provider = preg_replace(
'/-.*$/',
'', $key);
169 $provider = ucfirst(strtolower($provider));
171 $oauthservices[$key] = $name.
" (".$provider.
")";
176if ($action ==
'edit') {
177 if ($conf->use_javascript_ajax) {
178 print
"\n".
'<script type="text/javascript">';
179 print
'jQuery(document).ready(function () {
180 function initfields()
182 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\')
184 jQuery(".hideifdefault").hide();
188 jQuery(".hideifdefault").show();
191 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\')
193 jQuery(".drag").hide();
194 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
195 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
196 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
197 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
198 jQuery(".smtp_method").hide();
199 jQuery(".smtp_auth_method").hide();
203 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").hide();
204 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").hide();
205 jQuery("#smtp_server_mess").show();
206 jQuery("#smtp_port_mess").show();
210 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").prop("disabled", true);
211 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").prop("disabled", true);
212 jQuery("#smtp_server_mess").hide();
213 jQuery("#smtp_port_mess").hide();
218 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\')
220 jQuery(".drag").show();
221 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
222 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
223 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
224 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
225 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
226 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
227 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
228 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
229 jQuery("#smtp_server_mess").hide();
230 jQuery("#smtp_port_mess").hide();
231 jQuery(".smtp_method").show();
232 jQuery(".smtp_auth_method").show();
234 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
236 jQuery(".drag").show();
237 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET').
');
238 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
239 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET').
');
240 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").removeAttr("disabled");
241 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").removeAttr("disabled");
242 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").removeAttr("disabled");
243 jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
244 jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
245 jQuery("#smtp_server_mess").hide();
246 jQuery("#smtp_port_mess").hide();
247 jQuery(".smtp_method").show();
248 jQuery(".smtp_auth_method").show();
251 function change_smtp_auth_method() {
252 console.log(jQuery("#radio_pw").prop("checked"));
253 if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
254 jQuery(".smtp_oauth_service").show();
255 jQuery(".smtp_pw").hide();
256 } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
257 jQuery(".smtp_oauth_service").show();
258 jQuery(".smtp_pw").hide();
259 } else if(jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\'){
260 jQuery(".smtp_oauth_service").hide();
261 jQuery(".smtp_pw").hide();
263 jQuery(".smtp_oauth_service").hide();
264 jQuery(".smtp_pw").show();
268 change_smtp_auth_method();
270 jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
272 change_smtp_auth_method();
275 jQuery("#radio_pw, #radio_oauth").change(function() {
276 change_smtp_auth_method();
278 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
279 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
280 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
282 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").change(function() {
283 if (jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val() == 1)
284 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0);
287 print
'</script>'.
"\n";
290 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
291 print
'<input type="hidden" name="token" value="'.newToken().
'">';
292 print
'<input type="hidden" name="action" value="update">';
296 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
302 print
'<table class="noborder centpercent">';
303 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
307 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
310 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
311 print $form->selectarray(
'MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
315 $text = $langs->trans(
"Undefined");
317 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
318 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
319 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET').
'">';
325 print
'<tr class="oddeven hideifdefault">';
326 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
328 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
330 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
334 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER_TICKET') ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'');
335 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
337 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
339 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
343 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
344 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" size="18" value="'.$mainserver.
'">';
345 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET_sav" name="MAIN_MAIL_SMTP_SERVER_TICKET_sav" value="'.$mainserver.
'">';
346 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
347 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
349 $text = !empty($mainserver) ? $mainserver : $smtpserver;
350 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
351 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
352 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.
'">';
360 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
361 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail') {
362 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
364 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
366 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT_TICKET') ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'');
367 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
369 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
371 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
375 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
376 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.
'">';
377 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.
'">';
378 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
380 $text = (!empty($mainport) ? $mainport : $smtpport);
381 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
382 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
383 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.
'">';
389 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
390 print
'<tr class="oddeven smtp_auth_method hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
391 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
393 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
394 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
395 print
' ';
396 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
397 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
400 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
401 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
402 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.
'">';
408 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
409 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET :
'');
410 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
412 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
413 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
415 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
416 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1,
'superadmin');
417 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
423 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
424 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET :
'');
425 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
427 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
428 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
430 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
431 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1,
'superadmin');
432 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
438 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
439 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
441 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
442 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
446 $text = $langs->trans(
"Undefined");
448 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
449 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
450 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').
'">';
457 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
458 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
459 if (function_exists(
'openssl_open')) {
460 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
462 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
465 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
471 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
472 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
473 if (function_exists(
'openssl_open')) {
474 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
476 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
479 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
487 print $form->buttonsSaveCancel();
493 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
496 print
'<div class="div-table-responsive-no-min">';
497 print
'<table class="noborder centpercent">';
498 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
501 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
504 $text = $langs->trans(
"Undefined").img_warning();
507 print
'<span class="opacitymedium">'.$text.
'</span>';
518 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>';
525 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>';
529 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
531 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
532 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
536 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
537 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET').
'</td></tr>';
541 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") {
542 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).
'</td></tr>';
549 $text = $langs->trans(
"Undefined").img_warning();
551 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").
'</td><td>'.$text.
'</td></tr>';
558 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
559 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
560 if (function_exists(
'openssl_open')) {
561 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
563 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
566 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
575 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
576 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
577 if (function_exists(
'openssl_open')) {
578 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
580 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
583 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
608 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
614 print
'<div class="tabsAction">';
616 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
620 if (function_exists(
'fsockopen') && $port && $server) {
621 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
624 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
627 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
629 if (isModEnabled(
'fckeditor')) {
630 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
637 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
638 $text = $langs->trans(
"WarningPHPMail");
643 if ($action ==
'testconnect') {
644 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
647 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
648 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
650 $result = $mail->check_server_port($server, $port);
652 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
654 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
657 $errormsg .=
' - '.$mail->error;
666 if ($action ==
'test' || $action ==
'testhtml') {
667 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
668 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
673 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
675 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
676 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
677 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
678 $formmail->fromid = $user->id;
679 $formmail->fromalsorobot = 1;
680 $formmail->withfromreadonly = 0;
681 $formmail->withsubstit = 0;
682 $formmail->withfrom = 1;
683 $formmail->witherrorsto = 1;
684 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
685 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
686 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
687 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
688 $formmail->withtopicreadonly = 0;
689 $formmail->withfile = 2;
690 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
691 $formmail->withbodyreadonly = 0;
692 $formmail->withcancel = 1;
693 $formmail->withdeliveryreceipt = 1;
694 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
695 $formmail->ckeditortoolbar =
'dolibarr_mailings';
697 $formmail->substit = $substitutionarrayfortest;
699 $formmail->param[
"action"] =
"send";
700 $formmail->param[
"models"] =
"body";
701 $formmail->param[
"mailid"] = 0;
702 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
705 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
706 $formmail->clear_attached_files();
709 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 informations.
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($titre, $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.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.