30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
36$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
38$action =
GETPOST(
'action',
'aZ09');
39$cancel =
GETPOST(
'cancel',
'aZ09');
47$usersignature = $user->signature;
49if ($action ==
'test' || ($action ==
'send' && $trackid =
'test')) {
53$substitutionarrayfortest = array(
54 '__USER_LOGIN__' => $user->login,
55 '__USER_EMAIL__' => $user->email,
56 '__USER_FIRSTNAME__' => $user->firstname,
57 '__USER_LASTNAME__' => $user->lastname,
58 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
59 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
62 '__LASTNAME__' => $langs->trans(
"Lastname").
' ('.$langs->trans(
"Recipient").
')',
63 '__FIRSTNAME__' => $langs->trans(
"Firstname").
' ('.$langs->trans(
"Recipient").
')',
68 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
69 '__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" />',
79if ($action ==
'update' && !$cancel) {
80 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
82 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
87 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
93 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOSTINT(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT"),
'chaine', 0,
'', $conf->entity);
99 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
100 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
101 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
102 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW",
GETPOST(
"MAIN_MAIL_SMTPS_PW",
'password'),
'chaine', 0,
'', $conf->entity);
104 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
105 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
107 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
108 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
112 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOSTINT(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED"),
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
116 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
119 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
120 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
121 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
122 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
125 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
130if ($action ==
'disablephpmailwarning' && !$cancel) {
131 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1,
'', $conf->entity);
139$triggersendname =
'';
141$mode =
'emailfortest';
142$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
143$sendcontext =
'standard';
144include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
146if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
149if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
150 $action =
'testhtml';
158$form =
new Form($db);
162if (preg_match(
'/^win/i', PHP_OS)) {
165if (preg_match(
'/^mac/i', PHP_OS)) {
170 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
173$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT', (
int) ini_get(
'smtp_port'));
179 $server =
'127.0.0.1';
183$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
184llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails');
191$listofmethods = array();
192$listofmethods[
'mail'] =
'PHP mail function';
193$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
194if (version_compare(phpversion(),
'7.0',
'>=')) {
195 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
199$oauthservices = array();
201foreach ($conf->global as $key => $val) {
202 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
203 $key = preg_replace(
'/^OAUTH_/',
'', $key);
204 $key = preg_replace(
'/_ID$/',
'', $key);
205 if (preg_match(
'/^.*-/', $key)) {
206 $name = preg_replace(
'/^.*-/',
'', $key);
208 $name = $langs->trans(
"NoName");
210 $provider = preg_replace(
'/-.*$/',
'', $key);
211 $provider = ucfirst(strtolower($provider));
213 $oauthservices[$key] = $name.
" (".$provider.
")";
217if ($action ==
'edit') {
218 if ($conf->use_javascript_ajax) {
219 print
"\n".
'<script type="text/javascript">';
220 print
'jQuery(document).ready(function () {
221 function initfields()
223 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
225 console.log("I choose php mail mode");
226 jQuery(".drag").hide();
227 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
228 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
230 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
231 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
232 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
233 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
234 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
235 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
236 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
237 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
238 jQuery(".smtp_method").hide();
239 jQuery(".dkim").hide();
240 jQuery(".smtp_auth_method").hide();
244 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
245 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
246 jQuery("#smtp_server_mess").show();
247 jQuery("#smtp_port_mess").show();';
250 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
251 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
252 jQuery("#smtp_server_mess").hide();
253 jQuery("#smtp_port_mess").hide();';
257 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
259 console.log("I choose smtps mode");
260 jQuery(".drag").show();
262 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
263 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
264 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
265 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
266 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
270 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
271 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
272 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
273 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
274 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
275 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
276 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
277 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
278 jQuery("#MAIN_MAIL_SMTP_PORT").show();
279 jQuery("#smtp_server_mess").hide();
280 jQuery("#smtp_port_mess").hide();
281 jQuery(".smtp_method").show();
282 jQuery(".dkim").hide();
283 jQuery(".smtp_auth_method").show();
285 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
287 console.log("I choose swiftmailer mode");
288 jQuery(".drag").show();
290 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
291 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
292 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
293 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
294 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
295 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
296 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
297 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
298 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
299 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
300 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
301 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
302 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
303 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
304 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
305 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
306 jQuery("#MAIN_MAIL_SMTP_PORT").show();
307 jQuery("#smtp_server_mess").hide();
308 jQuery("#smtp_port_mess").hide();
309 jQuery(".smtp_method").show();
310 jQuery(".dkim").show();
311 jQuery(".smtp_auth_method").show();
314 function change_smtp_auth_method() {
315 console.log("Call smtp auth method");
316 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') {
317 if (jQuery("#radio_oauth").prop("checked")) {
318 jQuery(".smtp_pw").hide();
319 jQuery(".smtp_oauth_service").show();
321 jQuery(".smtp_pw").show();
322 jQuery(".smtp_oauth_service").hide();
324 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') {
325 if (jQuery("#radio_oauth").prop("checked")) {
326 jQuery(".smtp_pw").hide();
327 jQuery(".smtp_oauth_service").show();
329 jQuery(".smtp_pw").show();
330 jQuery(".smtp_oauth_service").hide();
333 jQuery(".smtp_pw").show();
334 jQuery(".smtp_oauth_service").hide();
338 change_smtp_auth_method();
339 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
341 change_smtp_auth_method();
343 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
344 change_smtp_auth_method();
346 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
347 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
348 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
350 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
352 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
353 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
354 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
356 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
359 print
'</script>'.
"\n";
362 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
363 print
'<input type="hidden" name="token" value="'.newToken().
'">';
364 print
'<input type="hidden" name="action" value="update">';
368 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
375 print
'<table class="noborder centpercent">';
376 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
379 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
382 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
383 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
387 $text = $langs->trans(
"Undefined");
389 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
390 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
391 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
396 print
'<tr class="oddeven hideonmodemail">';
397 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
399 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
401 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
405 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
406 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
408 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
410 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
414 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
415 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
416 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
417 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
418 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
420 $text = !empty($mainserver) ? $mainserver : $smtpserver;
421 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
422 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
423 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
430 print
'<tr class="oddeven hideonmodemail"><td>';
431 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
432 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
434 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
436 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
437 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
439 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
441 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
445 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
446 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
447 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
448 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
450 $text = (!empty($mainport) ? $mainport : $smtpport);
451 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
452 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
453 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
459 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
460 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
461 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE';
462 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
464 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
465 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
467 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
468 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
470 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
471 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
472 if (!isModEnabled(
'oauth')) {
473 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
475 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
479 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
480 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
481 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
487 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
488 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID') ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
489 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
491 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
492 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
494 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
495 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
496 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
503 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
505 print
'<tr class="drag drop oddeven smtp_pw"><td>';
506 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
509 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
510 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
512 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
513 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW'), $htmltext, 1,
'superadmin');
514 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
520 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
521 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
524 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
525 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
529 $text = $langs->trans(
"Undefined");
531 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
532 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
533 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
539 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
540 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
541 if (function_exists(
'openssl_open')) {
542 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS') ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
544 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
547 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
552 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
553 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
554 if (function_exists(
'openssl_open')) {
555 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
557 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
560 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
565 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
566 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
567 if (function_exists(
'openssl_open')) {
568 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
570 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
573 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
578 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
579 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
580 if (function_exists(
'openssl_open')) {
581 print $form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
583 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
586 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
591 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
592 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') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN :
'');
593 print
'"></td></tr>';
596 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
597 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') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR :
'');
598 print
'"></td></tr>';
601 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
602 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') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY :
'').
'</textarea>';
611 print
'<table class="noborder centpercent">';
612 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
615 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
616 print
'<input class="flat width300" name="MAIN_MAIL_FORCE_SENDTO" value="'.getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO').
'" />';
620 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
621 print
'<tr class="oddeven"><td class="fieldrequired">';
622 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
625 print
'<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM" value="'.(getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM') ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
626 print
'"></td></tr>';
630 $liste[
'user'] = $langs->trans(
'UserEmail');
631 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(!
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL') ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
633 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
634 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
638 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
639 print
'<td><input class="flat width300" name="MAIN_MAIL_ERRORS_TO" value="'.getDolGlobalString(
'MAIN_MAIL_ERRORS_TO').
'">';
643 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
644 print
'<td><input class="flat width300" name="MAIN_MAIL_AUTOCOPY_TO" value="'.getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO').
'">';
648 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
649 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
652 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
653 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
660 print $form->buttonsSaveCancel();
666 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
669 print $langs->trans(
"MAIN_DISABLE_ALL_MAILS");
670 if (!empty($conf->use_javascript_ajax)) {
671 print ajax_constantonoff(
'MAIN_DISABLE_ALL_MAILS', array(),
null, 0, 0, 1, 2, 0, 0,
'_red').
'</a>';
685 print
'<div class="div-table-responsive-no-min">';
686 print
'<table class="noborder centpercent">';
687 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
690 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
693 $text = $langs->trans(
"Undefined").img_warning();
699 $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");
700 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'help',
'nomargintop');
709 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') ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'').
'</td></tr>';
717 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') ? $conf->global->MAIN_MAIL_SMTP_PORT :
'').
'</td></tr>';
721 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
724 if ($authtype ===
"LOGIN") {
725 $text = $langs->trans(
"UseAUTHLOGIN");
726 } elseif ($authtype ===
"PLAIN") {
727 $text = $langs->trans(
"UseAUTHPLAIN");
728 } elseif ($authtype ===
"XOAUTH2") {
729 $text = $langs->trans(
"UseOauth");
731 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
735 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
736 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
741 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
748 $text = $langs->trans(
"Undefined").img_warning();
750 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
757 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
758 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
759 if (function_exists(
'openssl_open')) {
762 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
765 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
774 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
775 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
776 if (function_exists(
'openssl_open')) {
779 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
791 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
792 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
793 if (function_exists(
'openssl_open')) {
796 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
799 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
806 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
807 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
808 if (function_exists(
'openssl_open')) {
811 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
814 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
819 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
820 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
824 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
825 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
829 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
830 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
838 $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");
839 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
840 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
841 $linktosetvar2 =
'</a>';
842 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
843 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
845 print
info_admin($messagetoshow, 0, 0,
'warning',
'nomargintop',
'',
'warning');
876 print
'<div class="div-table-responsive-no-min">';
877 print
'<table class="noborder centpercent">';
878 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
882 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
887 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
894 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
895 print
'<tr class="oddeven"><td>';
896 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
902 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
909 $liste[
'user'] = $langs->trans(
'UserEmail');
910 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')';
911 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
912 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
913 $resql = $db->query($sql);
915 $num = $db->num_rows($resql);
918 $obj = $db->fetch_object($resql);
920 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
928 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
931 print $langs->trans(
'RobotEmail');
933 print $langs->trans(
'UserEmail');
939 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
941 $emailsenderprofile->fetch($id);
942 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
948 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
949 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
956 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
961 foreach ($listofemail as $key => $val) {
968 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
978 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>';
980 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>';
990 print
'<div class="tabsAction">';
992 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
996 if (function_exists(
'fsockopen') && $port && $server) {
997 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&token='.
newToken().
'&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
1003 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
1005 if (isModEnabled(
'fckeditor')) {
1006 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
1024 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
1027 if (!in_array($action, array(
'testconnect',
'test',
'testhtml')) && !
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS')) {
1037 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPFDMARC");
1042 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPFDMARC");
1049 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPF",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
1054 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS'));
1059 $emailstotest = array();
1066 if (!empty($user->email)) {
1067 $emailstotest[$user->email] =
getDomainFromURL(preg_replace(
'/^.*@/',
'', $user->email), 1);
1069 $domainstotest = array();
1070 foreach ($emailstotest as $email => $domain) {
1071 if (empty($domainstotest[$domain])) {
1072 $domainstotest[$domain] = array($email => $email);
1074 $domainstotest[$domain][$email] = $email;
1079 foreach (array(
'SPF',
'DMARC') as $dnstype) {
1080 foreach ($domainstotest as $domaintotest => $listofemails) {
1083 if (!empty($domaintotest) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1084 $domain = $domaintotest;
1085 if ($dnstype ==
'DMARC') {
1086 $domain =
'_dmarc.'.$domain;
1088 $dnsinfo = dns_get_record($domain, DNS_TXT);
1090 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1091 foreach ($dnsinfo as $info) {
1092 if (($dnstype ==
'SPF' && stripos($info[
'txt'],
'v=spf') !==
false)
1093 || ($dnstype ==
'DMARC' && stripos($info[
'txt'],
'v=dmarc') !==
false)) {
1095 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitylow">'.$info[
'txt'].
'</span>');
1099 if (!$foundforemail) {
1100 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitymedium">'.$langs->transnoentitiesnoconv(
"None").
'</span>');
1106 print
info_admin($langs->trans(
"SPFAndDMARCInformation").
' :<br>'.$text, 0, 0,
'1',
'');
1111 if ($action ==
'testconnect') {
1112 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1115 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1116 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
1117 $result = $mail->check_server_port($server, $port);
1119 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1121 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1124 $errormsg .=
' - '.$mail->error;
1133 if ($action ==
'test' || $action ==
'testhtml') {
1134 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1135 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1140 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1142 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1145 $formmail->fromid = $user->id;
1146 $formmail->fromalsorobot = 1;
1147 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') :
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'user'));
1148 $formmail->withfromreadonly = 1;
1149 $formmail->withsubstit = 1;
1150 $formmail->withfrom = 1;
1151 $formmail->witherrorsto = 1;
1152 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
1153 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1154 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1155 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1156 $formmail->withtopicreadonly = 0;
1157 $formmail->withfile = 2;
1159 $formmail->withlayout =
'emailing';
1160 $formmail->withaiprompt = ($action ==
'testhtml' ?
'html' :
'text');
1162 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1163 $formmail->withbodyreadonly = 0;
1164 $formmail->withcancel = 1;
1165 $formmail->withdeliveryreceipt = 1;
1166 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1167 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1169 $formmail->substit = $substitutionarrayfortest;
1171 $formmail->param[
"action"] =
"send";
1172 $formmail->param[
"models"] =
"body";
1173 $formmail->param[
"mailid"] = 0;
1174 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1177 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1178 $formmail->clear_attached_files();
1181 print $formmail->get_form(
'addfile',
'removefile');
1186 if (!empty($user->admin)) {
1188 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
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,...
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").
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_now($mode='auto')
Return date for now.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.