28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
34$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
36$action =
GETPOST(
'action',
'aZ09');
37$cancel =
GETPOST(
'cancel',
'aZ09');
45$usersignature = $user->signature;
47if ($action ==
'test' || ($action ==
'send' && $trackid ==
'test')) {
51$substitutionarrayfortest = array(
52 '__USER_LOGIN__' => $user->login,
53 '__USER_EMAIL__' => $user->email,
54 '__USER_FIRSTNAME__' => $user->firstname,
55 '__USER_LASTNAME__' => $user->lastname,
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 :
''),
60 '__LASTNAME__' => $langs->trans(
"Lastname").
' ('.$langs->trans(
"Recipient").
')',
61 '__FIRSTNAME__' => $langs->trans(
"Firstname").
' ('.$langs->trans(
"Recipient").
')',
66 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
67 '__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" />',
77if ($action ==
'update' && !$cancel) {
78 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
80 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
85 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
91 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
92 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOSTINT(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT"),
'chaine', 0,
'', $conf->entity);
97 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
99 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
102 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
103 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
105 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
106 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
110 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOSTINT(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED"),
'chaine', 0,
'', $conf->entity);
113 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
114 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
118 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
119 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
120 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
123 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
128if ($action ==
'disablephpmailwarning' && !$cancel) {
129 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1, 0, $conf->entity);
137$triggersendname =
'';
139$mode =
'emailfortest';
140$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
142include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
144if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
147if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
148 $action =
'testhtml';
156$form =
new Form($db);
159if (preg_match(
'/^win/i', PHP_OS)) {
162if (preg_match(
'/^mac/i', PHP_OS)) {
167 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
169$port =
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
173$server =
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
175 $server =
'127.0.0.1';
179$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
180llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails');
187$listofmethods = array();
188$listofmethods[
'mail'] =
'PHP mail function';
189$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
190if (version_compare(phpversion(),
'7.0',
'>=')) {
191 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
195$oauthservices = array();
197foreach ($conf->global as $key => $val) {
198 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
199 $key = preg_replace(
'/^OAUTH_/',
'', $key);
200 $key = preg_replace(
'/_ID$/',
'', $key);
201 if (preg_match(
'/^.*-/', $key)) {
202 $name = preg_replace(
'/^.*-/',
'', $key);
204 $name = $langs->trans(
"NoName");
206 $provider = preg_replace(
'/-.*$/',
'', $key);
207 $provider = ucfirst(strtolower($provider));
209 $oauthservices[$key] = $name.
" (".$provider.
")";
213if ($action ==
'edit') {
214 if ($conf->use_javascript_ajax) {
215 print
"\n".
'<script type="text/javascript">';
216 print
'jQuery(document).ready(function () {
217 function initfields()
219 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
221 console.log("I choose php mail mode");
222 jQuery(".drag").hide();
223 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
224 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
225 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
226 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
228 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
232 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
233 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
234 jQuery(".smtp_method").hide();
235 jQuery(".dkim").hide();
236 jQuery(".smtp_auth_method").hide();
240 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
241 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
242 jQuery("#smtp_server_mess").show();
243 jQuery("#smtp_port_mess").show();';
246 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
247 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
248 jQuery("#smtp_server_mess").hide();
249 jQuery("#smtp_port_mess").hide();';
253 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
255 console.log("I choose smtps mode");
256 jQuery(".drag").show();
258 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
260 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
261 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
262 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
263 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
264 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
265 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
266 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
270 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
271 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
272 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
273 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
274 jQuery("#MAIN_MAIL_SMTP_PORT").show();
275 jQuery("#smtp_server_mess").hide();
276 jQuery("#smtp_port_mess").hide();
277 jQuery(".smtp_method").show();
278 jQuery(".dkim").hide();
279 jQuery(".smtp_auth_method").show();
281 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
283 console.log("I choose swiftmailer mode");
284 jQuery(".drag").show();
286 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
288 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
289 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
290 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
291 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
292 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
293 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
294 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
295 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
296 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
297 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
298 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
299 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
300 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
301 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
302 jQuery("#MAIN_MAIL_SMTP_PORT").show();
303 jQuery("#smtp_server_mess").hide();
304 jQuery("#smtp_port_mess").hide();
305 jQuery(".smtp_method").show();
306 jQuery(".dkim").show();
307 jQuery(".smtp_auth_method").show();
310 function change_smtp_auth_method() {
311 console.log("Call smtp auth method");
312 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
313 jQuery(".smtp_pw").hide();
314 jQuery(".smtp_oauth_service").show();
315 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
316 jQuery(".smtp_pw").hide();
317 jQuery(".smtp_oauth_service").show();
318 } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
319 jQuery(".smtp_pw").hide();
320 jQuery(".smtp_oauth_service").hide();
322 jQuery(".smtp_pw").show();
323 jQuery(".smtp_oauth_service").hide();
327 change_smtp_auth_method();
328 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
330 change_smtp_auth_method();
332 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
333 change_smtp_auth_method();
335 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
336 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
337 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
339 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
341 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
342 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
343 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
345 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
348 print
'</script>'.
"\n";
351 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
352 print
'<input type="hidden" name="token" value="'.newToken().
'">';
353 print
'<input type="hidden" name="action" value="update">';
357 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
364 print
'<table class="noborder centpercent">';
365 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
368 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
371 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
372 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
376 $text = $langs->trans(
"Undefined");
378 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
379 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
380 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
385 print
'<tr class="oddeven hideonmodemail">';
386 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
388 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
390 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
394 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
395 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
397 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
399 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
403 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
404 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
405 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
406 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
407 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
409 $text = !empty($mainserver) ? $mainserver : $smtpserver;
410 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
411 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
412 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
419 print
'<tr class="oddeven hideonmodemail"><td>';
420 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
421 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
423 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
425 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
426 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
428 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
430 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
434 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
435 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
436 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
437 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
439 $text = (!empty($mainport) ? $mainport : $smtpport);
440 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
441 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
442 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
448 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
449 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
450 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE';
451 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
453 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
454 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
456 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype,
'PLAIN') ==
'PLAIN' ?
' checked' :
'').
'> ';
457 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
459 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
460 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
461 if (!isModEnabled(
'oauth')) {
462 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
464 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
468 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
469 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
470 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
476 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
477 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID') ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
478 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
480 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
481 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
483 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
484 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
485 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
492 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
493 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW') ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
494 print
'<tr class="drag drop oddeven smtp_pw"><td>';
495 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
498 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
499 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
501 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
502 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
503 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
509 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
510 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
513 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
514 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE'));
518 $text = $langs->trans(
"Undefined");
520 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
521 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
522 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
528 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
529 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
530 if (function_exists(
'openssl_open')) {
531 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS') ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
533 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
536 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
541 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
542 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
543 if (function_exists(
'openssl_open')) {
544 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
546 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
549 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
554 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
555 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
556 if (function_exists(
'openssl_open')) {
557 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);
559 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
562 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
567 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
568 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
569 if (function_exists(
'openssl_open')) {
570 print $form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
572 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
575 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
580 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
581 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 :
'');
582 print
'"></td></tr>';
585 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
586 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 :
'');
587 print
'"></td></tr>';
590 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
591 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>';
600 print
'<table class="noborder centpercent">';
601 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"ParametersForTestEnvironment").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
604 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
605 print $form->selectyesno(
'MAIN_DISABLE_ALL_MAILS',
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS'), 1);
609 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
610 print
'<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO') ? $conf->global->MAIN_MAIL_FORCE_SENDTO :
'').
'" />';
619 print
'<table class="noborder centpercent">';
620 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
623 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
624 print
'<tr class="oddeven"><td class="fieldrequired">';
625 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
628 print
'<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM" value="'.(getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM') ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
629 print
'"></td></tr>';
633 $liste[
'user'] = $langs->trans(
'UserEmail');
634 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(!
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL') ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
636 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
637 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
641 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
642 print
'<td><input class="flat width300" name="MAIN_MAIL_ERRORS_TO" value="'.getDolGlobalString(
'MAIN_MAIL_ERRORS_TO').
'">';
646 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
647 print
'<td><input class="flat width300" name="MAIN_MAIL_AUTOCOPY_TO" value="'.getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO').
'">';
651 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
652 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
655 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
656 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
663 print $form->buttonsSaveCancel();
669 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
674 print
'<div class="div-table-responsive-no-min">';
675 print
'<table class="noborder centpercent">';
676 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
679 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
682 $text = $langs->trans(
"Undefined").img_warning();
688 $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");
689 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'help',
'nomargintop');
698 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>';
706 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>';
710 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
713 if ($authtype ===
"LOGIN") {
714 $text = $langs->trans(
"UseAUTHLOGIN");
715 } elseif ($authtype ===
"PLAIN") {
716 $text = $langs->trans(
"UseAUTHPLAIN");
717 } elseif ($authtype ===
"XOAUTH2") {
718 $text = $langs->trans(
"UseOauth");
720 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
724 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
725 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
730 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
737 $text = $langs->trans(
"Undefined").img_warning();
739 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
746 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
747 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
748 if (function_exists(
'openssl_open')) {
751 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
754 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
763 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
764 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
765 if (function_exists(
'openssl_open')) {
768 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
780 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
781 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
782 if (function_exists(
'openssl_open')) {
785 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
788 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
795 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
796 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
797 if (function_exists(
'openssl_open')) {
800 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
803 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
808 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
809 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
813 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
814 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
818 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
819 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
827 $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");
828 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
829 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
830 $linktosetvar2 =
'</a>';
831 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
832 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
834 print
info_admin($messagetoshow, 0, 0,
'warning',
'nomargintop',
'',
'warning');
841 print
'<div class="div-table-responsive-no-min">';
842 print
'<table class="noborder centpercent">';
843 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"ParametersForTestEnvironment").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
846 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
847 if (!empty($conf->use_javascript_ajax)) {
848 print ajax_constantonoff(
'MAIN_DISABLE_ALL_MAILS', array(),
null, 0, 0, 1, 2, 0, 0,
'_red').
'</a>';
859 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
864 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
877 print
'<div class="div-table-responsive-no-min">';
878 print
'<table class="noborder centpercent">';
879 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
882 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
883 print
'<tr class="oddeven"><td>';
884 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
890 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
897 $liste[
'user'] = $langs->trans(
'UserEmail');
898 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')';
899 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
900 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
901 $resql = $db->query($sql);
903 $num = $db->num_rows($resql);
906 $obj = $db->fetch_object($resql);
908 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
916 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
919 print $langs->trans(
'RobotEmail');
921 print $langs->trans(
'UserEmail');
925 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
927 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
929 $emailsenderprofile->fetch($id);
930 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
936 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
937 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
944 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
949 foreach ($listofemail as $key => $val) {
956 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
966 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>';
968 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>';
978 print
'<div class="tabsAction">';
980 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
984 if (function_exists(
'fsockopen') && $port && $server) {
985 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
991 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
993 if (isModEnabled(
'fckeditor')) {
994 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
1013 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
1016 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
1026 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPFDMARC");
1031 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPFDMARC");
1038 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMailSPF",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
1043 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS'));
1048 $emailstotest = array();
1055 if (!empty($user->email)) {
1056 $emailstotest[$user->email] =
getDomainFromURL(preg_replace(
'/^.*@/',
'', $user->email), 1);
1058 $domainstotest = array();
1059 foreach ($emailstotest as $email => $domain) {
1060 if (empty($domainstotest[$domain])) {
1061 $domainstotest[$domain] = array($email => $email);
1063 $domainstotest[$domain][$email] = $email;
1068 foreach (array(
'SPF',
'DMARC') as $dnstype) {
1069 foreach ($domainstotest as $domaintotest => $listofemails) {
1072 if (!empty($domaintotest) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1073 $domain = $domaintotest;
1074 if ($dnstype ==
'DMARC') {
1075 $domain =
'_dmarc.'.$domain;
1077 $dnsinfo = dns_get_record($domain, DNS_TXT);
1079 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1080 foreach ($dnsinfo as $info) {
1081 if (($dnstype ==
'SPF' && stripos($info[
'txt'],
'v=spf') !==
false)
1082 || ($dnstype ==
'DMARC' && stripos($info[
'txt'],
'v=dmarc') !==
false)) {
1084 $text .= ($text ?
'<br>' :
'').$langs->trans(
"ActualMailDNSRecordFound", $dnstype, implode(
', ', $listofemails), $info[
'txt']);
1088 if (!$foundforemail) {
1089 $text .= ($text ?
'<br>' :
'').$langs->trans(
"ActualMailDNSRecordFound", $dnstype, implode(
', ', $listofemails),
'<span class="opacitymedium">'.$langs->transnoentitiesnoconv(
"None").
'</span>');
1095 print
info_admin($langs->trans(
"SPFAndDMARCInformation").
' :<br>'.$text, 0, 0,
'1',
'');
1100 if ($action ==
'testconnect') {
1101 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1104 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1105 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
1106 $result = $mail->check_server_port($server, $port);
1108 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1110 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1113 $errormsg .=
' - '.$mail->error;
1122 if ($action ==
'test' || $action ==
'testhtml') {
1123 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1124 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1129 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1131 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1134 $formmail->fromid = $user->id;
1135 $formmail->fromalsorobot = 1;
1136 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') :
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'user'));
1137 $formmail->withfromreadonly = 1;
1138 $formmail->withsubstit = 1;
1139 $formmail->withfrom = 1;
1140 $formmail->witherrorsto = 1;
1141 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
1142 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1143 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1144 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1145 $formmail->withtopicreadonly = 0;
1146 $formmail->withfile = 2;
1147 $formmail->withlayout = 1;
1148 $formmail->withaiprompt = ($action ==
'testhtml' ?
'html' :
'text');
1149 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1150 $formmail->withbodyreadonly = 0;
1151 $formmail->withcancel = 1;
1152 $formmail->withdeliveryreceipt = 1;
1153 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1154 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1156 $formmail->substit = $substitutionarrayfortest;
1158 $formmail->param[
"action"] =
"send";
1159 $formmail->param[
"models"] =
"body";
1160 $formmail->param[
"mailid"] = 0;
1161 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1164 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1165 $formmail->clear_attached_files();
1168 print $formmail->get_form(
'addfile',
'removefile');
1173 if (!empty($user->admin)) {
1175 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()
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class for EmailSenderProfile.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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'.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.