28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
35$action =
GETPOST(
'action',
'aZ09');
36$cancel =
GETPOST(
'cancel',
'aZ09');
44$usersignature = $user->signature;
46if ($action ==
'test' || ($action ==
'send' && $trackid =
'test')) {
50$substitutionarrayfortest = array(
51 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
52 '__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" />',
53 '__USER_LOGIN__' => $user->login,
54 '__USER_EMAIL__' => $user->email,
55 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
56 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
57 '__ID__' =>
'RecipientIdRecord',
59 '__LOGIN__' => $user->login,
60 '__LASTNAME__' =>
'RecipientLastname',
61 '__FIRSTNAME__' =>
'RecipientFirstname',
62 '__ADDRESS__'=>
'RecipientAddress',
63 '__ZIP__'=>
'RecipientZip',
64 '__TOWN_'=>
'RecipientTown',
65 '__COUNTRY__'=>
'RecipientCountry'
75if ($action ==
'update' && !$cancel) {
76 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
78 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
83 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
88 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
89 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
90 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
91 dolibarr_set_const($db,
'MAIN_MAIL_NO_WITH_TO_SELECTED',
GETPOST(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
'int'),
'chaine', 0,
'', $conf->entity);
95 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
96 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
97 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
100 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
101 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'chaine'),
'chaine', 0,
'', $conf->entity);
103 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
104 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'chaine'),
'chaine', 0,
'', $conf->entity);
107 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
108 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
110 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
111 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
112 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
113 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
116 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
118 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
121 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
126if ($action ==
'disablephpmailwarning' && !$cancel) {
127 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1, 0, $conf->entity);
135$triggersendname =
'';
137$mode =
'emailfortest';
138$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
140include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
142if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
145if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
146 $action =
'testhtml';
155$form =
new Form($db);
158if (preg_match(
'/^win/i', PHP_OS)) {
161if (preg_match(
'/^mac/i', PHP_OS)) {
165if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
166 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
168$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
172$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
174 $server =
'127.0.0.1';
178$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
179llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
186$listofmethods = array();
187$listofmethods[
'mail'] =
'PHP mail function';
188$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
189if (version_compare(phpversion(),
'7.0',
'>=')) {
190 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
194$oauthservices = array();
196foreach ($conf->global as $key => $val) {
197 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
198 $key = preg_replace(
'/^OAUTH_/',
'', $key);
199 $key = preg_replace(
'/_ID$/',
'', $key);
200 if (preg_match(
'/^.*-/', $key)) {
201 $name = preg_replace(
'/^.*-/',
'', $key);
203 $name = $langs->trans(
"NoName");
205 $provider = preg_replace(
'/-.*$/',
'', $key);
206 $provider = ucfirst(strtolower($provider));
208 $oauthservices[$key] = $name.
" (".$provider.
")";
212if ($action ==
'edit') {
213 if ($conf->use_javascript_ajax) {
214 print
"\n".
'<script type="text/javascript">';
215 print
'jQuery(document).ready(function () {
216 function initfields()
218 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
220 console.log("I choose php mail mode");
221 jQuery(".drag").hide();
222 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
223 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
224 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
225 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
226 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
227 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
232 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
233 jQuery(".smtp_method").hide();
234 jQuery(".dkim").hide();
235 jQuery(".smtp_auth_method").hide();
239 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
240 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
241 jQuery("#smtp_server_mess").show();
242 jQuery("#smtp_port_mess").show();';
245 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
246 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
247 jQuery("#smtp_server_mess").hide();
248 jQuery("#smtp_port_mess").hide();';
252 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
254 console.log("I choose smtps mode");
255 jQuery(".drag").show();
256 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
257 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
258 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
259 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
260 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
261 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
262 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
263 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
264 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
265 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
266 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
269 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
270 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
271 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
272 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
273 jQuery("#MAIN_MAIL_SMTP_PORT").show();
274 jQuery("#smtp_server_mess").hide();
275 jQuery("#smtp_port_mess").hide();
276 jQuery(".smtp_method").show();
277 jQuery(".dkim").hide();
278 jQuery(".smtp_auth_method").show();
280 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
282 console.log("I choose swiftmailer mode");
283 jQuery(".drag").show();
284 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
285 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
286 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
287 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
288 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
289 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
290 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.
');
291 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
292 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
293 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
294 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
295 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
296 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
297 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
298 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
299 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
300 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
301 jQuery("#MAIN_MAIL_SMTP_PORT").show();
302 jQuery("#smtp_server_mess").hide();
303 jQuery("#smtp_port_mess").hide();
304 jQuery(".smtp_method").show();
305 jQuery(".dkim").show();
306 jQuery(".smtp_auth_method").show();
309 function change_smtp_auth_method() {
310 console.log(jQuery("#radio_pw").prop("checked"));
311 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
312 jQuery(".smtp_oauth_service").show();
313 jQuery(".smtp_pw").hide();
314 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
315 jQuery(".smtp_oauth_service").show();
316 jQuery(".smtp_pw").hide();
317 } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
318 jQuery(".smtp_oauth_service").hide();
319 jQuery(".smtp_pw").hide();
321 jQuery(".smtp_oauth_service").hide();
322 jQuery(".smtp_pw").show();
326 change_smtp_auth_method();
327 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
329 change_smtp_auth_method();
331 jQuery("#radio_pw, #radio_oauth").change(function() {
332 change_smtp_auth_method();
334 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
335 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
336 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
338 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
340 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
341 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
342 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
344 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
347 print
'</script>'.
"\n";
350 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
351 print
'<input type="hidden" name="token" value="'.newToken().
'">';
352 print
'<input type="hidden" name="action" value="update">';
356 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
362 print
'<table class="noborder centpercent">';
363 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
366 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
367 print $form->selectyesno(
'MAIN_DISABLE_ALL_MAILS',
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS'), 1);
371 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
372 print
'<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO :
'').
'" />';
379 print
'<table class="noborder centpercent">';
380 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
383 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
386 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
387 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
389 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
391 $text = $langs->trans(
"Undefined");
393 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
394 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
395 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
400 print
'<tr class="oddeven">';
401 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
403 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
405 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
409 $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
410 $smtpserver = ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
412 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
414 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
418 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
419 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
420 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
421 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
422 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
424 $text = !empty($mainserver) ? $mainserver : $smtpserver;
425 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
426 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
427 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
434 print
'<tr class="oddeven"><td>';
435 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
436 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
438 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
440 $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
441 $smtpport = ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
443 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
445 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
449 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
450 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
451 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
452 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
454 $text = (!empty($mainport) ? $mainport : $smtpport);
455 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
456 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
457 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
463 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
464 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
465 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
467 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
468 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
469 print
' ';
470 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
471 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
474 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
475 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
476 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
482 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
483 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
484 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
486 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
487 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
489 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
490 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
491 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
498 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
499 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
500 print
'<tr class="drag drop oddeven smtp_pw"><td>';
501 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
504 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
505 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
507 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
508 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
509 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
515 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
516 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
519 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
520 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
522 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
524 $text = $langs->trans(
"Undefined");
526 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
527 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
528 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE.
'">';
533 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
534 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
535 if (function_exists(
'openssl_open')) {
536 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
538 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
541 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
546 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
547 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
548 if (function_exists(
'openssl_open')) {
549 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
551 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
554 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
559 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
560 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
561 if (function_exists(
'openssl_open')) {
562 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (!empty($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED) ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0), 1);
564 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
567 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
572 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
573 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
574 if (function_exists(
'openssl_open')) {
575 print $form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
577 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
580 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
585 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
586 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN :
'');
587 print
'"></td></tr>';
590 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
591 print
'<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR :
'');
592 print
'"></td></tr>';
595 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
596 print
'<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY :
'').
'</textarea>';
603 print
'<table class="noborder centpercent">';
604 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
607 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
608 print
'<tr class="oddeven"><td class="fieldrequired">'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
' '.$help.
'</td>';
609 print
'<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
610 print
'"></td></tr>';
614 $liste[
'user'] = $langs->trans(
'UserEmail');
615 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
617 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
618 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
622 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
623 print
'<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO :
'');
624 print
'"></td></tr>';
627 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
628 print
'<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO :
'');
629 print
'"></td></tr>';
632 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
633 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
636 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
637 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
644 print $form->buttonsSaveCancel();
650 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
653 print
'<div class="div-table-responsive-no-min">';
654 print
'<table class="noborder centpercent">';
655 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
658 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
659 if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
664 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
666 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
671 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
680 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
683 print
'<div class="div-table-responsive-no-min">';
684 print
'<table class="noborder centpercent">';
685 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
688 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
691 $text = $langs->trans(
"Undefined").img_warning();
695 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
696 $textwarning = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
697 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'warning');
704 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
706 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER", ini_get(
'SMTP') ?ini_get(
'SMTP') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'').
'</td></tr>';
712 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
714 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT", ini_get(
'smtp_port') ?ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined")).
'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'').
'</td></tr>';
718 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
720 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
721 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
725 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
726 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.
'</td></tr>';
731 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW).
'</td></tr>';
736 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
738 $text = $langs->trans(
"Undefined").img_warning();
740 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
744 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
745 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
746 if (function_exists(
'openssl_open')) {
747 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
749 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
752 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
757 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
758 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
759 if (function_exists(
'openssl_open')) {
760 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
762 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
765 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
770 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
771 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
772 if (function_exists(
'openssl_open')) {
773 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
775 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
778 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
783 if ($conf->global->MAIN_MAIL_SENDMODE ==
'swiftmailer') {
785 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
786 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
787 if (function_exists(
'openssl_open')) {
790 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
793 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
798 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
799 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
803 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
804 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
808 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
809 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
816 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
817 $messagetoshow = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
818 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
819 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.newToken().
'">';
820 $linktosetvar2 =
'</a>';
821 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
822 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
823 print
info_admin($messagetoshow, 0, 0,
'warning');
828 print
'<div class="div-table-responsive-no-min">';
829 print
'<table class="noborder centpercent">';
830 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
833 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
834 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
' '.$help.
'</td>';
835 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
836 if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
838 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
845 $liste[
'user'] = $langs->trans(
'UserEmail');
846 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
847 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
848 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
849 $resql = $db->query($sql);
851 $num = $db->num_rows($resql);
854 $obj = $db->fetch_object($resql);
856 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
864 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
867 print $langs->trans(
'RobotEmail');
869 print $langs->trans(
'UserEmail');
873 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
875 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
877 $emailsenderprofile->fetch($id);
878 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
884 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
885 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
886 if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !
isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
892 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
894 if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
895 $listofemail = explode(
',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
897 foreach ($listofemail as $key => $val) {
904 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
914 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>'.
yn(!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)).
'</td></tr>';
916 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>'.
yn(!empty($conf->global->MAIN_MAIL_NO_WITH_TO_SELECTED)).
'</td></tr>';
926 print
'<div class="tabsAction">';
928 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
930 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
932 if (function_exists(
'fsockopen') && $port && $server) {
933 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
939 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
941 if (isModEnabled(
'fckeditor')) {
942 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
949 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
961 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
964 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
971 if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
973 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
976 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
978 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
982 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
985 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
987 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) {
989 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
994 if (!empty($companyemail) && function_exists(
'dns_get_record')) {
995 $arrayofemailparts = explode(
'@', $companyemail);
996 if (count($arrayofemailparts) == 2) {
997 $domain = $arrayofemailparts[1];
998 $dnsinfo = dns_get_record($domain, DNS_TXT);
1001 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1002 foreach ($dnsinfo as $info) {
1003 if (strpos($info[
'txt'],
'v=spf') !==
false) {
1004 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $companyemail, $info[
'txt']);
1014 if ($action ==
'testconnect') {
1015 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1018 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1019 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
1020 $result = $mail->check_server_port($server, $port);
1022 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1024 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1027 $errormsg .=
' - '.$mail->error;
1036 if ($action ==
'test' || $action ==
'testhtml') {
1037 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1038 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1043 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1045 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1046 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1047 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1048 $formmail->fromid = $user->id;
1049 $formmail->fromalsorobot = 1;
1050 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
1051 $formmail->withfromreadonly = 1;
1052 $formmail->withsubstit = 1;
1053 $formmail->withfrom = 1;
1054 $formmail->witherrorsto = 1;
1055 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
1056 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1057 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1058 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1059 $formmail->withtopicreadonly = 0;
1060 $formmail->withfile = 2;
1061 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1062 $formmail->withbodyreadonly = 0;
1063 $formmail->withcancel = 1;
1064 $formmail->withdeliveryreceipt = 1;
1065 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1066 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1068 $formmail->substit = $substitutionarrayfortest;
1070 $formmail->param[
"action"] =
"send";
1071 $formmail->param[
"models"] =
"body";
1072 $formmail->param[
"mailid"] = 0;
1073 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1076 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1077 $formmail->clear_attached_files();
1080 print $formmail->get_form(
'addfile',
'removefile');
1086 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 informations.
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant int value.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...
dol_hash($chain, $type='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.