32require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
46$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other"));
48$action =
GETPOST(
'action',
'aZ09');
49$cancel =
GETPOST(
'cancel',
'alpha');
57$usersignature = $user->signature;
59if ($action ==
'test' || ($action ==
'send' && $trackid ==
'test')) {
63$substitutionarrayfortest = array(
64 '__USER_LOGIN__' => $user->login,
65 '__USER_EMAIL__' => $user->email,
66 '__USER_FIRSTNAME__' => $user->firstname,
67 '__USER_LASTNAME__' => $user->lastname,
68 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
69 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
72 '__LASTNAME__' => $langs->trans(
"Lastname").
' ('.$langs->trans(
"MailRecipient").
')',
73 '__FIRSTNAME__' => $langs->trans(
"Firstname").
' ('.$langs->trans(
"MailRecipient").
')',
78 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
79 '__CHECK_READ__' =>
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag=undefinedtag&securitykey='.
dol_hash(
getDolGlobalString(
'MAILING_EMAIL_UNSUBSCRIBE_KEY').
"-undefinedtag",
'md5').
'" width="1" height="1" style="width:1px;height:1px" border="0" />',
90if ($action ==
'update' && !$cancel) {
91 if (!
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
93 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
98 $langs->load(
'errors');
99 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
108 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS',
GETPOST(
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS',
'restricthtml'),
'chaine', 0,
'',
$conf->entity);
123 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
131 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
132 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'',
$conf->entity);
140 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
145if ($action ==
'disablephpmailwarning' && !$cancel) {
148 setEventMessages($langs->trans(
"WarningDisabled"),
null,
'mesgs');
154$triggersendname =
'';
156$mode =
'emailfortest';
157$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
158$sendcontext =
'standard';
159include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
161if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
164if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
165 $action =
'testhtml';
173$form =
new Form($db);
177if (preg_match(
'/^win/i', PHP_OS)) {
180if (preg_match(
'/^mac/i', PHP_OS)) {
185 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
188$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT', (
int) ini_get(
'smtp_port'));
194 $server =
'127.0.0.1';
198$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
199llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails');
206$listofmethods = array();
207$listofmethods[
'mail'] =
'PHP mail function';
208$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
209$listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
212$oauthservices = array();
214foreach (
$conf->global as $key => $val) {
215 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
216 $key = preg_replace(
'/^OAUTH_/',
'', $key);
217 $key = preg_replace(
'/_ID$/',
'', $key);
218 if (preg_match(
'/^.*-/', $key)) {
219 $name = preg_replace(
'/^.*-/',
'', $key);
221 $name = $langs->trans(
"NoName");
223 $provider = preg_replace(
'/-.*$/',
'', $key);
224 $provider = ucfirst(strtolower($provider));
226 $oauthservices[$key] = $name.
" (".$provider.
")";
230if ($action ==
'edit') {
231 if (
$conf->use_javascript_ajax) {
232 print
"\n".
'<script type="text/javascript">';
233 print
'jQuery(document).ready(function () {
234 function initfields()
236 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
238 console.log("I choose php mail mode");
239 jQuery(".drag").hide();
240 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
241 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
242 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
243 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
244 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
245 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
246 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
247 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
248 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
249 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
250 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
251 jQuery(".smtp_method").hide();
252 jQuery(".dkim").hide();
253 jQuery(".smtp_auth_method").hide();
257 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
258 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
259 jQuery("#smtp_server_mess").show();
260 jQuery("#smtp_port_mess").show();';
263 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
264 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
265 jQuery("#smtp_server_mess").hide();
266 jQuery("#smtp_port_mess").hide();';
270 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
272 console.log("I choose smtps mode");
273 jQuery(".drag").show();
275 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
277 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
278 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
279 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
283 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
284 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
285 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
286 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
287 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
288 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
289 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
290 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
291 jQuery("#MAIN_MAIL_SMTP_PORT").show();
292 jQuery("#smtp_server_mess").hide();
293 jQuery("#smtp_port_mess").hide();
294 jQuery(".smtp_method").show();
295 jQuery(".dkim").hide();
296 jQuery(".smtp_auth_method").show();
298 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
300 console.log("I choose swiftmailer mode");
301 jQuery(".drag").show();
303 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
304 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
305 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
306 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
307 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
308 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
309 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
310 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
311 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
312 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
313 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
314 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
315 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
316 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
317 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
318 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
319 jQuery("#MAIN_MAIL_SMTP_PORT").show();
320 jQuery("#smtp_server_mess").hide();
321 jQuery("#smtp_port_mess").hide();
322 jQuery(".smtp_method").show();
323 jQuery(".dkim").show();
324 jQuery(".smtp_auth_method").show();
327 function change_smtp_auth_method() {
328 console.log("Call smtp auth method");
329 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') {
330 if (jQuery("#radio_oauth").prop("checked")) {
331 jQuery(".smtp_pw").hide();
332 jQuery(".smtp_oauth_service").show();
334 jQuery(".smtp_pw").show();
335 jQuery(".smtp_oauth_service").hide();
337 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') {
338 if (jQuery("#radio_oauth").prop("checked")) {
339 jQuery(".smtp_pw").hide();
340 jQuery(".smtp_oauth_service").show();
342 jQuery(".smtp_pw").show();
343 jQuery(".smtp_oauth_service").hide();
346 jQuery(".smtp_pw").show();
347 jQuery(".smtp_oauth_service").hide();
351 change_smtp_auth_method();
352 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
354 change_smtp_auth_method();
356 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
357 change_smtp_auth_method();
359 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
360 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
361 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
363 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
365 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
366 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
367 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
369 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
372 print
'</script>'.
"\n";
375 print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
376 print
'<input type="hidden" name="token" value="'.newToken().
'">';
377 print
'<input type="hidden" name="action" value="update">';
381 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
388 print
'<div class="div-table-responsive-no-min">';
389 print
'<table class="noborder centpercent">';
390 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
393 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
396 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
397 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
401 $text = $langs->trans(
"Undefined");
403 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
404 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
405 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
410 print
'<tr class="oddeven hideonmodemail">';
413 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
415 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
420 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
422 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
424 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
428 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
429 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
430 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
431 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
432 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
434 $text = !empty($mainserver) ? $mainserver : $smtpserver;
435 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
436 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
437 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
444 print
'<tr class="oddeven hideonmodemail"><td>';
446 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
448 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
451 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
453 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
455 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
459 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
460 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
461 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
462 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
464 $text = (!empty($mainport) ? $mainport : $smtpport);
465 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
466 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
467 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
473 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
474 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
475 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE';
476 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
478 print
'<input type="radio" id="radio_none" name="'.$vartosmtpstype.
'" value="NONE"'.(
getDolGlobalString($vartosmtpstype) ==
'NONE' ?
' checked' :
'').
'> ';
479 print
'<label for="radio_none" >'.$langs->trans(
"UseAUTHNONE").
'</label>';
481 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
482 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
484 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype) ==
'PLAIN' ?
' checked' :
'').
'> ';
485 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
487 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(
isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
488 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
490 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
492 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
496 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
497 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
498 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
504 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
506 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
508 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
509 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'" autocomplete="new-password">';
511 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
512 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID'), $htmltext, 1,
'superadmin');
513 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
520 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
522 print
'<tr class="drag drop oddeven smtp_pw"><td>';
523 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
526 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
527 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="new-password">';
529 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
530 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW'), $htmltext, 1,
'superadmin');
531 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
537 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
538 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
541 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
542 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE'));
546 $text = $langs->trans(
"Undefined");
548 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
549 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
550 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
556 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
557 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
558 if (function_exists(
'openssl_open')) {
561 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
564 print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
569 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
570 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
571 if (function_exists(
'openssl_open')) {
574 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
577 print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
582 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
583 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
584 if (function_exists(
'openssl_open')) {
585 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') : 0), 1);
587 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
590 print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
595 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
596 if (!empty(
$conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
597 if (function_exists(
'openssl_open')) {
600 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
603 print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
608 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
609 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
610 print
'"></td></tr>';
613 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
614 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
615 print
'"></td></tr>';
618 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
619 print
'<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY').
'</textarea>';
627 print
'<div class="div-table-responsive-no-min">';
628 print
'<table class="noborder centpercent">';
629 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
632 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
633 print
'<input class="flat width300" name="MAIN_MAIL_FORCE_SENDTO" value="'.getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO').
'" />';
637 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
638 print
'<tr class="oddeven"><td class="fieldrequired">';
639 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
642 print
'<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM');
643 print
'"></td></tr>';
648 'label' => $langs->trans(
'UserEmail'),
649 'data-html' => $langs->trans(
'UserEmail')
652 'label' => $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')',
653 'data-html' => $langs->trans(
'CompanyEmail').
' <span class="opacitymedium">('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')</span>'
657 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
658 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
662 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
663 print
'<td><input class="flat width300" name="MAIN_MAIL_ERRORS_TO" value="'.getDolGlobalString(
'MAIN_MAIL_ERRORS_TO').
'">';
667 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
668 print
'<td><input class="flat width300" name="MAIN_MAIL_AUTOCOPY_TO" value="'.getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO').
'">';
672 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
673 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
676 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
677 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
680 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
681 $doleditor =
new DolEditor(
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'),
'', 138,
'dolibarr_notes',
'In',
true,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, 0,
'90%');
682 $text = $langs->trans(
"MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS");
683 $texthelp = $langs->trans(
"MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS_Help");
684 print
'<tr class="oddeven"><td>'.$form->textwithpicto($text, $texthelp, 1,
'help').
'</td><td>'.$doleditor->Create(1).
'</td></tr>';
691 print $form->buttonsSaveCancel();
697 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
700 print
'<div class="neutral nomargintop">';
701 print $langs->trans(
"MAIN_DISABLE_ALL_MAILS");
702 if (!empty(
$conf->use_javascript_ajax)) {
703 print ajax_constantonoff(
'MAIN_DISABLE_ALL_MAILS', array(),
null, 0, 0, 1, 2, 0, 0,
'_red').
'</a>';
707 print img_warning($langs->trans(
"Disabled"));
716 print
'<div class="div-table-responsive-no-min">';
717 print
'<table class="noborder centpercent">';
718 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
721 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
724 $text = $langs->trans(
"Undefined").img_warning();
730 $textwarning = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
731 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'help',
'nomargintop');
740 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER').
'</td></tr>';
748 print
'<tr class="oddeven"><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').
'</td></tr>';
752 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
755 if ($authtype ===
"NONE") {
756 $text = $langs->trans(
"None");
757 } elseif ($authtype ===
"LOGIN") {
758 $text = $langs->trans(
"UseAUTHLOGIN");
759 } elseif ($authtype ===
"PLAIN") {
760 $text = $langs->trans(
"UseAUTHPLAIN");
761 } elseif ($authtype ===
"XOAUTH2") {
762 $text = $langs->trans(
"UseOauth");
764 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
768 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
769 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
774 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
781 $text = $langs->trans(
"Undefined").img_warning();
783 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
790 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
791 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
792 if (function_exists(
'openssl_open')) {
795 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
798 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
807 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
808 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
809 if (function_exists(
'openssl_open')) {
812 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
824 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
825 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
826 if (function_exists(
'openssl_open')) {
829 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
832 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
839 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
840 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
841 if (function_exists(
'openssl_open')) {
844 print yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
847 print yn(0).
' ('.$langs->trans(
"NotSupported").
')';
852 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
853 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
857 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
858 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
862 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
863 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
871 $messagetoshow = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
872 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
873 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
874 $linktosetvar2 =
'</a>';
875 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
876 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
878 print
info_admin($messagetoshow, 0, 0,
'warning',
'nomargintop',
'',
'warning');
909 print
'<div class="div-table-responsive-no-min">';
910 print
'<table class="noborder centpercent">';
911 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
915 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
918 $langs->load(
'errors');
919 print img_warning($langs->trans(
"ErrorBadEMail",
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO')));
921 print img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
928 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
929 print
'<tr class="oddeven"><td>';
930 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
935 print img_warning($langs->trans(
"Mandatory"));
937 $langs->load(
'errors');
938 print img_warning($langs->trans(
"ErrorBadEMail",
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM')));
944 $liste[
'user'] = $langs->trans(
'UserEmail');
945 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')';
946 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
947 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
948 $resql = $db->query($sql);
950 $num = $db->num_rows($resql);
953 $obj = $db->fetch_object($resql);
955 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
960 dol_print_error($db);
963 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
966 print $langs->trans(
'RobotEmail');
968 print $langs->trans(
'UserEmail');
974 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
976 $emailsenderprofile->fetch($id);
977 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
983 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
984 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
986 $langs->load(
'errors');
987 print img_warning($langs->trans(
"ErrorBadEMail",
getDolGlobalString(
'MAIN_MAIL_ERRORS_TO')));
992 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
997 foreach ($listofemail as $key => $val) {
1004 $langs->load(
'errors');
1005 print img_warning($langs->trans(
"ErrorBadEMail", $val));
1015 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.yn(
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT')).
'</td></tr>';
1017 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>'.yn(
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED')).
'</td></tr>';
1019 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1020 $doleditor =
new DolEditor(
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'),
'', 138,
'dolibarr_notes',
'In',
true,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, 0,
'90%', 1);
1021 $text = $langs->trans(
"MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS");
1022 $texthelp = $langs->trans(
"MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS_Help");
1023 print
'<tr class="oddeven"><td>'.$form->textwithpicto($text, $texthelp, 1,
'help').
'</td><td>'.$doleditor->Create(1).
'</td></tr>';
1032 print
'<div class="tabsAction">';
1034 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
1038 if (function_exists(
'fsockopen') ) {
1039 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1040 $mailtest =
new CMailFile(
'test',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
1041 $testconnectrefusal = $mailtest->checkSmtpTargetAllowed((
string) $server, (
int) $port);
1042 print dolGetButtonAction($testconnectrefusal, $langs->trans(
"DoTestServerAvailability"),
'default', $_SERVER[
"PHP_SELF"].
'?action=testconnect&token='.
newToken().
'&date='.
dol_now().
'#formmailaftertstconnect',
'', $testconnectrefusal ? -1 : 1);
1048 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
1051 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
1073 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
1076 if (!in_array($action, array(
'testconnect',
'test',
'testhtml')) && !
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS')) {
1086 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1091 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1098 $text .= $langs->trans(
"WarningPHPMailSPF",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
1103 $arrayipstoshow = explode(
',',
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS'));
1104 foreach ($arrayipstoshow as $iptoshow) {
1106 if (preg_match(
'/^http/i', $iptoshow)) {
1107 $tmpresult =
getURLContent($iptoshow,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1108 if (!empty($tmpresult[
'content'])) {
1109 $iptoshow = $tmpresult[
'content'];
1114 $ipstoshow .= ($ipstoshow ?
', ' :
'').trim($iptoshow);
1117 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2", $ipstoshow);
1123 $emailstotest = array();
1130 if (!empty($user->email)) {
1131 $emailstotest[$user->email] =
getDomainFromURL(preg_replace(
'/^.*@/',
'', $user->email), 1);
1133 $domainstotest = array();
1134 foreach ($emailstotest as $email => $domain) {
1135 if (empty($domainstotest[$domain])) {
1136 $domainstotest[$domain] = array($email => $email);
1138 $domainstotest[$domain][$email] = $email;
1143 if ($action ==
'testsetup') {
1144 foreach (array(
'SPF',
'DMARC') as $dnstype) {
1145 foreach ($domainstotest as $domaintotest => $listofemails) {
1148 if (!empty($domaintotest) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1149 $domain = $domaintotest;
1150 if ($dnstype ==
'DMARC') {
1151 $domain =
'_dmarc.'.$domain;
1155 $dnsinfo = @dns_get_record($domain, DNS_TXT, $authns);
1156 if ($dnsinfo ===
false) {
1157 $langs->load(
"errors");
1158 $text .= ($text ?
'<br>' :
'').$langs->trans(
"WarningDNSServerNotAvailable");
1162 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1163 foreach ($dnsinfo as $info) {
1164 if (($dnstype ==
'SPF' && stripos($info[
'txt'],
'v=spf') !==
false)
1165 || ($dnstype ==
'DMARC' && stripos($info[
'txt'],
'v=dmarc') !==
false)) {
1167 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitylow">'.$info[
'txt'].
'</span>');
1171 if (!$foundforemail) {
1172 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitymedium">'.$langs->transnoentitiesnoconv(
"None").
'</span>');
1178 print
info_admin($langs->trans(
"SPFAndDMARCInformation").
' :<br>'.$text, 0, 0,
'1',
'');
1181 print img_picto(
'',
'info',
'class="pictofixedwidth"').
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=testsetup">'.$langs->trans(
"ClickHereToCheckSPFDMARCForSetup").
'...</a>';
1187 if ($action ==
'testconnect') {
1188 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1191 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1193 $mail =
new CMailFile(
'test',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
1195 $errormsg = $mail->checkSmtpTargetAllowed((
string) $server, (
int) $port);
1197 if (empty($errormsg)) {
1198 $result = $mail->check_server_port((
string) $server, (
int) $port);
1199 if ($result && !is_array($result)) {
1200 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", (
string) $server, (
string) $port).
'</div>';
1202 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", (
string) $server, (
string) $port);
1203 if (is_array($result)) {
1204 $errormsg .=
'<br>'.$result[
'content'];
1211 $errormsg .=
' - '.$mail->error;
1214 setEventMessages($errormsg,
null,
'errors');
1221 if ($action ==
'test' || $action ==
'testhtml') {
1222 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1223 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1228 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1230 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1233 $formmail->fromid = $user->id;
1234 $formmail->fromalsorobot = 1;
1236 $formmail->withfromreadonly = 1;
1237 $formmail->withsubstit = 1;
1238 $formmail->withfrom = 1;
1239 $formmail->witherrorsto = 1;
1241 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1242 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1243 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1244 $formmail->withtopicreadonly = 0;
1245 $formmail->withfile = 2;
1248 $formmail->withlayout =
'emailing';
1249 $formmail->withaiprompt = ($action ==
'testhtml' ?
'html' :
'text');
1251 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1252 $formmail->withbodyreadonly = 0;
1253 $formmail->withcancel = 1;
1254 $formmail->withdeliveryreceipt = 1;
1255 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1256 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1258 $formmail->substit = $substitutionarrayfortest;
1260 $formmail->param[
"action"] =
"send";
1261 $formmail->param[
"models"] =
"body";
1262 $formmail->param[
"mailid"] = 0;
1263 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1266 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1267 $formmail->clear_attached_files();
1270 print $formmail->get_form(
'addfile',
'removefile');
1275 if (!empty($user->admin)) {
1277 print
'<span class="opacitymedium wordwrap small">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
$id
Support class for third parties, contacts, members, users or resources.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
email_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage a WYSIWYG editor.
Class for EmailSenderProfile.
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").
dol_now($mode='gmt')
Return date for now.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getDomainFromURL($url, $mode=0)
Function get second level domain name.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array(), $morelogsuffix='')
Function to get a content from an URL (use proxy if proxy defined).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.