27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_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;
39 if ($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';
65 if (version_compare(phpversion(),
'7.0',
'>=')) {
66 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
79 if ($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);
86 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_TICKET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_TICKET",
'none'),
'chaine', 0,
'', $conf->entity);
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");
105 $actiontypecode =
'';
106 $triggersendname =
'';
108 $mode =
'emailfortest';
109 $trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
110 $sendcontext =
'ticket';
111 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
113 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
116 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
117 $action =
'testhtml';
127 $form =
new Form($db);
130 if (preg_match(
'/^win/i', PHP_OS)) {
133 if (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';
158 $oauthservices = array();
160 foreach ($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.
")";
177 if ($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").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").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").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 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
397 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' :
'').
'> ';
398 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
399 print
' ';
400 print
'<input type="radio" id="radio_plain" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="PLAIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET',
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
401 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
402 print
' ';
403 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' :
'').
'> ';
404 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
407 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
408 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
409 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET" value="'.$value.
'">';
415 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
416 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET :
'');
417 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
419 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
420 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_TICKET" size="32" value="'.$mainstmpid.
'">';
422 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
423 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_TICKET, $htmltext, 1,
'superadmin');
424 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_TICKET" value="'.$mainstmpid.
'">';
430 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
431 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET') ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET :
'');
432 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
434 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
435 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_TICKET" size="32" value="'.$mainsmtppw.
'">';
437 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
438 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_TICKET, $htmltext, 1,
'superadmin');
439 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_TICKET" value="'.$mainsmtppw.
'">';
445 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
446 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
448 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
449 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
453 $text = $langs->trans(
"Undefined");
455 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
456 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
457 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET').
'">';
464 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
465 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
466 if (function_exists(
'openssl_open')) {
467 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_TLS_TICKET : 0), 1);
469 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
472 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
478 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
479 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
480 if (function_exists(
'openssl_open')) {
481 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS_TICKET : 0), 1);
483 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
486 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
491 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
492 if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer')))) {
493 if (function_exists(
'openssl_open')) {
494 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);
496 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
499 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
507 print $form->buttonsSaveCancel();
513 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
516 print
'<div class="div-table-responsive-no-min">';
517 print
'<table class="noborder centpercent">';
518 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
521 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
524 $text = $langs->trans(
"Undefined").img_warning();
527 print
'<span class="opacitymedium">'.$text.
'</span>';
538 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>';
545 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>';
549 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET'), array(
'smtps',
'swiftmailer'))) {
552 if ($authtype ===
"LOGIN") {
553 $text = $langs->trans(
"UseAUTHLOGIN");
554 } elseif ($authtype ===
"PLAIN") {
555 $text = $langs->trans(
"UseAUTHPLAIN");
556 } elseif ($authtype ===
"XOAUTH2") {
557 $text = $langs->trans(
"UseOauth");
559 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
563 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
564 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_TICKET').
'</td></tr>';
568 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") {
569 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_TICKET')).
'</td></tr>';
576 $text = $langs->trans(
"Undefined").img_warning();
578 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").
'</td><td>'.$text.
'</td></tr>';
585 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
586 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
587 if (function_exists(
'openssl_open')) {
590 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
593 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
602 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
603 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
604 if (function_exists(
'openssl_open')) {
607 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
610 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
619 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
620 if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array(
'smtps',
'swiftmailer'))) {
621 if (function_exists(
'openssl_open')) {
624 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
627 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
652 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
658 print
'<div class="tabsAction">';
660 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
664 if (function_exists(
'fsockopen') && $port && $server) {
665 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
668 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
671 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
674 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
681 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_TICKET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
682 $text = $langs->trans(
"WarningPHPMail");
687 if ($action ==
'testconnect') {
688 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
691 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
692 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
694 $result = $mail->check_server_port($server, $port);
696 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
698 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
701 $errormsg .=
' - '.$mail->error;
710 if ($action ==
'test' || $action ==
'testhtml') {
711 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
712 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
717 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
721 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
722 $formmail->fromid = $user->id;
723 $formmail->fromalsorobot = 1;
724 $formmail->withfromreadonly = 0;
725 $formmail->withsubstit = 0;
726 $formmail->withfrom = 1;
727 $formmail->witherrorsto = 1;
728 $formmail->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
729 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
730 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
731 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
732 $formmail->withtopicreadonly = 0;
733 $formmail->withfile = 2;
734 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
735 $formmail->withbodyreadonly = 0;
736 $formmail->withcancel = 1;
737 $formmail->withdeliveryreceipt = 1;
738 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
739 $formmail->ckeditortoolbar =
'dolibarr_mailings';
741 $formmail->substit = $substitutionarrayfortest;
743 $formmail->param[
"action"] =
"send";
744 $formmail->param[
"models"] =
"body";
745 $formmail->param[
"mailid"] = 0;
746 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
749 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
750 $formmail->clear_attached_files();
753 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(GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) if(GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information in HTML for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.