28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41$langs->loadLangs(array(
'companies',
'products',
'admin',
'mails',
'other',
'errors'));
43$action =
GETPOST(
'action',
'aZ09');
44$cancel =
GETPOST(
'cancel',
'aZ09');
46$usersignature = $user->signature;
48if ($action ==
'test' || $action ==
'send') {
52$substitutionarrayfortest = array(
53 '__ID__' =>
'TESTIdRecord',
54 '__USER_LOGIN__' => $user->login,
55 '__USER_EMAIL__' => $user->email,
56 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
57 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
58 '__LASTNAME__' =>
'RecipientLastname',
59 '__FIRSTNAME__' =>
'RecipientFirstname',
60 '__ADDRESS__' =>
'RecipientAddress',
61 '__ZIP__' =>
'RecipientZip',
62 '__TOWN_' =>
'RecipientTown',
63 '__COUNTRY__' =>
'RecipientCountry',
64 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
69$listofmethods = array();
70$listofmethods[
'default'] = $langs->trans(
'DefaultOutgoingEmailSetup');
71$listofmethods[
'mail'] =
'PHP mail function';
73$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
74if (version_compare(phpversion(),
'7.0',
'>=')) {
75 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
88if ($action ==
'update' && !$cancel) {
94 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET")) {
95 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_PW_PASSWORDRESET",
'password'),
'chaine', 0,
'',
$conf->entity);
97 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET")) {
98 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
100 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET")) {
101 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
104 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET"),
'chaine', 0,
'',
$conf->entity);
105 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET"),
'chaine', 0,
'',
$conf->entity);
107 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
115$triggersendname =
'';
117$mode =
'emailfortest';
118$trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
119$sendcontext =
'ticket';
120include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
122if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
125if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
126 $action =
'testhtml';
136$form =
new Form($db);
139if (preg_match(
'/^win/i', PHP_OS)) {
142if (preg_match(
'/^mac/i', PHP_OS)) {
147 $conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET =
'default';
149$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT_PASSWORDRESET', (
int) ini_get(
'smtp_port'));
155 $server =
'127.0.0.1';
159$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
160llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails_passwordreset');
167$oauthservices = array();
169foreach (
$conf->global as $key => $val) {
170 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
171 $key = preg_replace(
'/^OAUTH_/',
'', $key);
172 $key = preg_replace(
'/_ID$/',
'', $key);
173 if (preg_match(
'/^.*-/', $key)) {
174 $name = preg_replace(
'/^.*-/',
'', $key);
176 $name = $langs->trans(
"NoName");
178 $provider = preg_replace(
'/-.*$/',
'', $key);
179 $provider = ucfirst(strtolower($provider));
181 $oauthservices[$key] = $name.
" (".$provider.
")";
186if ($action ==
'edit') {
187 if (
$conf->use_javascript_ajax) {
188 print
"\n".
'<script type="text/javascript">';
189 print
'jQuery(document).ready(function () {
190 function initfields()
192 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'default\')
194 jQuery(".hideifdefault").hide();
198 jQuery(".hideifdefault").show();
201 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'mail\')
203 console.log("I choose php mail mode");
204 jQuery(".drag").hide();
205 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(0);
206 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").prop("disabled", true);
207 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(0);
208 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").prop("disabled", true);
209 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(0);
210 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").prop("disabled", true);
211 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
212 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
213 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
214 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
215 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
216 jQuery(".smtp_method").hide();
217 jQuery(".dkim").hide();
218 jQuery(".smtp_auth_method").hide();
222 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").hide();
223 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").hide();
224 jQuery("#smtp_server_mess").show();
225 jQuery("#smtp_port_mess").show();
229 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").prop("disabled", true);
230 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").prop("disabled", true);
231 jQuery("#smtp_server_mess").hide();
232 jQuery("#smtp_port_mess").hide();
237 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'smtps\')
239 console.log("I choose smtps mail mode");
240 jQuery(".drag").show();
241 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET').
');
242 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").removeAttr("disabled");
243 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET').
');
244 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").removeAttr("disabled");
245 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET').
');
246 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").removeAttr("disabled");
247 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
248 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
249 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
250 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
251 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
252 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").hide();
253 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").hide();
254 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").hide();
255 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").removeAttr("disabled");
256 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").removeAttr("disabled");
257 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").show();
258 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").show();
259 jQuery("#smtp_server_mess").hide();
260 jQuery("#smtp_port_mess").hide();
261 jQuery(".smtp_method").show();
262 jQuery(".dkim").hide();
263 jQuery(".smtp_auth_method").show();
265 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'swiftmailer\')
267 console.log("I choose swiftmailer mail mode");
268 jQuery(".drag").show();
269 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET').
');
270 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").removeAttr("disabled");
271 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET').
');
272 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").removeAttr("disabled");
273 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET').
');
274 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET").removeAttr("disabled");
275 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").val(0);
276 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED_PASSWORDRESET").prop("disabled", true);
277 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").prop("disabled", true);
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").prop("disabled", true);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN_PASSWORDRESET").hide();
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR_PASSWORDRESET").hide();
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY_PASSWORDRESET").hide();
283 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").removeAttr("disabled");
284 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").removeAttr("disabled");
285 jQuery("#MAIN_MAIL_SMTP_SERVER_PASSWORDRESET").show();
286 jQuery("#MAIN_MAIL_SMTP_PORT_PASSWORDRESET").show();
287 jQuery("#smtp_server_mess").hide();
288 jQuery("#smtp_port_mess").hide();
289 jQuery(".smtp_method").show();
290 jQuery(".dkim").show();
291 jQuery(".smtp_auth_method").show();
294 function change_smtp_auth_method() {
295 console.log("Call smtp auth method");
296 if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'smtps\') {
297 if (jQuery("#radio_oauth").prop("checked")) {
298 jQuery(".smtp_pw").hide();
299 jQuery(".smtp_oauth_service").show();
301 jQuery(".smtp_pw").show();
302 jQuery(".smtp_oauth_service").hide();
304 } else if (jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").val()==\'swiftmailer\') {
305 if (jQuery("#radio_oauth").prop("checked")) {
306 jQuery(".smtp_pw").hide();
307 jQuery(".smtp_oauth_service").show();
309 jQuery(".smtp_pw").show();
310 jQuery(".smtp_oauth_service").hide();
313 jQuery(".smtp_pw").hide();
314 jQuery(".smtp_oauth_service").hide();
319 change_smtp_auth_method();
321 jQuery("#MAIN_MAIL_SENDMODE_PASSWORDRESET").change(function() {
323 change_smtp_auth_method();
325 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
326 change_smtp_auth_method();
328 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
329 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val() == 1)
330 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").val(0);
332 jQuery("#MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET").change(function() {
333 if (jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val() == 1)
334 jQuery("#MAIN_MAIL_EMAIL_TLS_PASSWORDRESET").val(0);
337 print
'</script>'.
"\n";
340 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
341 print
'<input type="hidden" name="token" value="'.newToken().
'">';
342 print
'<input type="hidden" name="action" value="update">';
346 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
352 print
'<table class="noborder centpercent">';
353 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
357 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
360 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
361 print $form->selectarray(
'MAIN_MAIL_SENDMODE_PASSWORDRESET', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'));
365 $text = $langs->trans(
"Undefined");
367 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
368 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
369 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE_PASSWORDRESET" value="' .
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET').
'">';
375 print
'<tr class="oddeven hideifdefault">';
376 if (!
$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail') {
378 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
380 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
385 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
387 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
389 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
393 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
394 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" size="18" value="'.$mainserver.
'">';
395 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET_sav" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET_sav" value="'.$mainserver.
'">';
396 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
397 print
' <span class="opacitymedium smtp_method">' . $langs->trans(
"SeeLinkToOnlineDocumentation") .
'</span>';
399 $text = !empty($mainserver) ? $mainserver : $smtpserver;
400 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
401 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
402 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" name="MAIN_MAIL_SMTP_SERVER_PASSWORDRESET" value="'.$mainserver.
'">';
410 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>';
411 if (!
$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail') {
412 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
414 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
417 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
419 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
421 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
425 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
426 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" size="3" value="'.$mainport.
'">';
427 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET_sav" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET_sav" value="'.$mainport.
'">';
428 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
430 $text = (!empty($mainport) ? $mainport : $smtpport);
431 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
432 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
433 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" name="MAIN_MAIL_SMTP_PORT_PASSWORDRESET" value="'.$mainport.
'">';
439 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
440 print
'<tr class="oddeven smtp_auth_method hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
441 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET';
442 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
444 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
445 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
447 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
448 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
450 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
451 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
452 if (!isModEnabled(
'oauth')) {
453 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
455 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
459 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
460 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
461 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET" value="'.$value.
'">';
467 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
469 print
'<tr class="drag drop oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
471 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
472 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID_PASSWORDRESET" size="32" value="'.$mainstmpid.
'">';
474 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
475 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_PASSWORDRESET'), $htmltext, 1,
'superadmin');
476 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID_PASSWORDRESET" value="'.$mainstmpid.
'">';
482 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
484 print
'<tr class="drag drop oddeven smtp_pw hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>';
486 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
487 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW_PASSWORDRESET" size="32" value="'.$mainsmtppw.
'">';
489 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
490 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_PASSWORDRESET'), $htmltext, 1,
'superadmin');
491 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW_PASSWORDRESET" value="'.$mainsmtppw.
'">';
497 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
498 print
'<tr class="oddeven smtp_oauth_service hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
500 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
501 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET'));
503 $text = $oauthservices[
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET')];
505 $text = $langs->trans(
"Undefined");
507 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
508 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
509 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET').
'">';
516 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
517 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
518 if (function_exists(
'openssl_open')) {
519 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS_PASSWORDRESET') : 0), 1);
521 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
524 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
530 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
531 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
532 if (function_exists(
'openssl_open')) {
533 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET') : 0), 1);
535 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
538 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
543 print
'<tr class="oddeven hideifdefault hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
544 if (!empty(
$conf->use_javascript_ajax) || in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
545 if (function_exists(
'openssl_open')) {
546 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET') : 0), 1);
548 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
551 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
559 print $form->buttonsSaveCancel();
565 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
568 print
'<div class="div-table-responsive-no-min">';
569 print
'<table class="noborder centpercent">';
570 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
573 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
576 $text = $langs->trans(
"Undefined").img_warning();
579 print
'<span class="opacitymedium">'.$text.
'</span>';
587 if ($linuxlike && (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail')) {
590 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_PASSWORDRESET').
'</td></tr>';
594 if ($linuxlike && (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail')) {
597 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_PASSWORDRESET').
'</td></tr>';
601 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
604 if ($authtype ===
"LOGIN") {
605 $text = $langs->trans(
"UseAUTHLOGIN");
606 } elseif ($authtype ===
"PLAIN") {
607 $text = $langs->trans(
"UseAUTHPLAIN");
608 } elseif ($authtype ===
"XOAUTH2") {
609 $text = $langs->trans(
"UseOauth");
611 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
615 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
616 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID_PASSWORDRESET').
'</td></tr>';
620 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET') !=
"XOAUTH2") {
621 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW_PASSWORDRESET')).
'</td></tr>';
625 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer')) &&
getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE_PASSWORDRESET') ===
"XOAUTH2") {
626 $text = $oauthservices[
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE_PASSWORDRESET')];
628 $text = $langs->trans(
"Undefined").img_warning();
630 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
637 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
638 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
639 if (function_exists(
'openssl_open')) {
642 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
645 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
654 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
655 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
656 if (function_exists(
'openssl_open')) {
659 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
662 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
671 print
'<tr class="oddeven hideifdefault"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
672 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET'), array(
'smtps',
'swiftmailer'))) {
673 if (function_exists(
'openssl_open')) {
674 print
yn(
getDolGlobalInt(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET'));
676 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
679 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
704 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
710 print
'<div class="tabsAction">';
712 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
715 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') !=
'mail' || !$linuxlike) {
716 if (function_exists(
'fsockopen') && $port && $server) {
717 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
720 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
723 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
725 if (isModEnabled(
'fckeditor')) {
726 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init">'.$langs->trans(
"DoTestSendHTML").
'</a>';
733 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE_PASSWORDRESET') ==
'mail' && !in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
734 $text = $langs->trans(
"WarningPHPMail");
739 if ($action ==
'testconnect') {
740 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
743 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
744 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
746 $result = $mail->check_server_port($server, $port);
748 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
750 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
753 $errormsg .=
' - '.$mail->error;
762 if ($action ==
'test' || $action ==
'testhtml') {
763 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
764 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
769 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
771 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
772 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail',
'restricthtml') :
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'));
773 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
774 $formmail->fromid = $user->id;
775 $formmail->fromalsorobot = 1;
776 $formmail->withfromreadonly = 0;
777 $formmail->withsubstit = 0;
778 $formmail->withfrom = 1;
779 $formmail->witherrorsto = 1;
780 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
781 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
782 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
783 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
784 $formmail->withtopicreadonly = 0;
785 $formmail->withfile = 2;
786 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
787 $formmail->withbodyreadonly = 0;
788 $formmail->withcancel = 1;
789 $formmail->withdeliveryreceipt = 1;
790 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
791 $formmail->ckeditortoolbar =
'dolibarr_mailings';
793 $formmail->substit = $substitutionarrayfortest;
795 $formmail->param[
"action"] =
"send";
796 $formmail->param[
"models"] =
"body";
797 $formmail->param[
"mailid"] = 0;
798 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
801 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
802 $formmail->clear_attached_files();
805 print $formmail->get_form(
'addfile',
'removefile');
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
email_admin_prepare_head()
Return array head with list of tabs to view object information.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($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").
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.