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 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
45 '__ID__' =>
'TESTIdRecord',
46 '__EMAIL__' =>
'TESTEMail',
47 '__LOGIN__' => $user->login,
48 '__LASTNAME__' =>
'TESTLastname',
49 '__FIRSTNAME__' =>
'TESTFirstname',
50 '__ADDRESS__'=>
'RecipientAddress',
51 '__ZIP__'=>
'RecipientZip',
52 '__TOWN_'=>
'RecipientTown',
53 '__COUNTRY__'=>
'RecipientCountry',
54 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
55 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
70if ($action ==
'update' && !$cancel) {
72 dolibarr_set_const($db,
"MAIN_MAIL_SENDMODE_TICKET",
GETPOST(
"MAIN_MAIL_SENDMODE_TICKET"),
'chaine', 0,
'', $conf->entity);
73 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_PORT_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_PORT_TICKET"),
'chaine', 0,
'', $conf->entity);
74 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER_TICKET",
GETPOST(
"MAIN_MAIL_SMTP_SERVER_TICKET"),
'chaine', 0,
'', $conf->entity);
75 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_ID_TICKET"),
'chaine', 0,
'', $conf->entity);
76 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_TICKET")) {
77 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_TICKET",
'none'),
'chaine', 0,
'', $conf->entity);
79 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
80 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET",
'chaine'),
'chaine', 0,
'', $conf->entity);
82 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
83 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET",
'chaine'),
'chaine', 0,
'', $conf->entity);
84 }
dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_TLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_TLS_TICKET"),
'chaine', 0,
'', $conf->entity);
85 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_TICKET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_TICKET"),
'chaine', 0,
'', $conf->entity);
87 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
97$mode =
'emailfortest';
98$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
99$sendcontext =
'ticket';
100include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
102if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
105if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
106 $action =
'testhtml';
116$form =
new Form($db);
119if (preg_match(
'/^win/i', PHP_OS)) {
122if (preg_match(
'/^mac/i', PHP_OS)) {
126if (empty($conf->global->MAIN_MAIL_SENDMODE_TICKET)) {
127 $conf->global->MAIN_MAIL_SENDMODE_TICKET =
'default';
129$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ini_get(
'smtp_port');
133$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ini_get(
'SMTP');
135 $server =
'127.0.0.1';
139$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
140llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
147$listofmethods = array();
148$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
149$listofmethods[
'mail'] =
'PHP mail function';
151$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
152if (version_compare(phpversion(),
'7.0',
'>=')) {
153 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
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('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.
');
222 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
223 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->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('.$conf->global->MAIN_MAIL_EMAIL_TLS_TICKET.
');
238 jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled");
239 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val('.$conf->global->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(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
307 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
310 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
311 print $form->selectarray(
'MAIN_MAIL_SENDMODE_TICKET', $listofmethods, $conf->global->MAIN_MAIL_SENDMODE_TICKET);
313 $text = $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="'.$conf->global->MAIN_MAIL_SENDMODE_TICKET.
'">';
325 print
'<tr class="oddeven hideifdefault">';
326 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->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 = (!empty($conf->global->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>';
348 $text = !empty($mainserver) ? $mainserver : $smtpserver;
349 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
350 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
351 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_TICKET" name="MAIN_MAIL_SMTP_SERVER_TICKET" value="'.$mainserver.
'">';
359 print
'<tr class="oddeven hideifdefault"><td>';
360 if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail') {
361 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
363 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
365 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'');
366 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
368 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
370 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
374 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
375 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" size="3" value="'.$mainport.
'">';
376 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET_sav" name="MAIN_MAIL_SMTP_PORT_TICKET_sav" value="'.$mainport.
'">';
377 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
379 $text = (!empty($mainport) ? $mainport : $smtpport);
380 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
381 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
382 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_TICKET" name="MAIN_MAIL_SMTP_PORT_TICKET" value="'.$mainport.
'">';
388 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
389 print
'<tr class="oddeven smtp_auth_method hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
390 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
392 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' :
'').
'> ';
393 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
394 print
' ';
395 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' :
'').
'> ';
396 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
399 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
400 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
401 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.
'">';
407 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
408 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET :
'');
409 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
411 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
412 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
414 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
415 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1,
'superadmin');
416 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
422 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
423 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET :
'');
424 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
426 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
427 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
429 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
430 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1,
'superadmin');
431 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
437 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
438 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
440 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
441 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
443 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
445 $text = $langs->trans(
"Undefined");
447 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
448 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
449 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET.
'">';
456 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
457 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
458 if (function_exists(
'openssl_open')) {
459 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
461 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
464 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
470 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</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_STARTTLS_TICKET', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
475 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
478 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
486 print $form->buttonsSaveCancel();
492 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
495 print
'<table class="noborder centpercent">';
496 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
499 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
502 $text = $langs->trans(
"Undefined").img_warning();
505 print
'<span class="opacitymedium">'.$text.
'</span>';
511 if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'default') {
513 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail')) {
514 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
516 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET :
'').
'</td></tr>';
520 if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail')) {
521 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td>'.$langs->trans(
"SeeLocalSendMailSetup").
'</td></tr>';
523 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>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET :
'').
'</td></tr>';
527 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
529 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
530 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
534 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
535 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.
'</td></tr>';
539 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") {
540 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>';
545 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
547 $text = $langs->trans(
"Undefined").img_warning();
549 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").
'</td><td>'.$text.
'</td></tr>';
553 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
554 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
555 if (function_exists(
'openssl_open')) {
556 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS_TICKET);
558 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
561 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
566 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
567 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
568 if (function_exists(
'openssl_open')) {
569 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET);
571 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
574 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
584 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
597 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
603 print
'<div class="tabsAction">';
605 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
607 if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'default') {
608 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET !=
'mail' || !$linuxlike) {
609 if (function_exists(
'fsockopen') && $port && $server) {
610 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
613 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
616 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
618 if (isModEnabled(
'fckeditor')) {
619 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
626 if ($conf->global->MAIN_MAIL_SENDMODE_TICKET ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
627 $text = $langs->trans(
"WarningPHPMail");
632 if ($action ==
'testconnect') {
633 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
636 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
637 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
639 $result = $mail->check_server_port($server, $port);
641 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
643 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
646 $errormsg .=
' - '.$mail->error;
655 if ($action ==
'test' || $action ==
'testhtml') {
656 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
657 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
662 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
664 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
665 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
666 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
667 $formmail->withfromreadonly = 0;
668 $formmail->withsubstit = 0;
669 $formmail->withfrom = 1;
670 $formmail->witherrorsto = 1;
671 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
672 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
673 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
674 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
675 $formmail->withtopicreadonly = 0;
676 $formmail->withfile = 2;
677 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
678 $formmail->withbodyreadonly = 0;
679 $formmail->withcancel = 1;
680 $formmail->withdeliveryreceipt = 1;
681 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
682 $formmail->ckeditortoolbar =
'dolibarr_mailings';
684 $formmail->substit = $substitutionarrayfortest;
686 $formmail->param[
"action"] =
"send";
687 $formmail->param[
"models"] =
"body";
688 $formmail->param[
"mailid"] = 0;
689 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
692 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
693 $formmail->clear_attached_files();
696 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.