27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 $langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
34 $action =
GETPOST(
'action',
'aZ09');
35 $cancel =
GETPOST(
'cancel',
'aZ09');
43 $usersignature = $user->signature;
45 if ($action ==
'test' || ($action ==
'send' && $trackid =
'test')) {
49 $substitutionarrayfortest = array(
50 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
51 '__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ?
'<img src="'.DOL_MAIN_URL_ROOT.
'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.
'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).
'" width="1" height="1" style="width:1px;height:1px" border="0"/>' :
'',
52 '__USER_LOGIN__' => $user->login,
53 '__USER_EMAIL__' => $user->email,
54 '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
55 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature :
''),
56 '__ID__' =>
'RecipientIdRecord',
58 '__LASTNAME__' =>
'RecipientLastname',
59 '__FIRSTNAME__' =>
'RecipientFirstname',
60 '__ADDRESS__'=>
'RecipientAddress',
61 '__ZIP__'=>
'RecipientZip',
62 '__TOWN_'=>
'RecipientTown',
63 '__COUNTRY__'=>
'RecipientCountry'
73 if ($action ==
'update' && !$cancel) {
74 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
76 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
81 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
86 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
87 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
88 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
92 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
93 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
98 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'chaine'),
'chaine', 0,
'', $conf->entity);
101 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'chaine'),
'chaine', 0,
'', $conf->entity);
104 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
105 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
107 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
108 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
109 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
110 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
112 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
113 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
114 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
122 if ($action ==
'disablephpmailwarning' && !$cancel) {
123 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1, 0, $conf->entity);
130 $actiontypecode =
'';
131 $triggersendname =
'';
133 $mode =
'emailfortest';
134 $trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
136 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
138 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
141 if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
142 $action =
'testhtml';
154 if (preg_match(
'/^win/i', PHP_OS)) {
157 if (preg_match(
'/^mac/i', PHP_OS)) {
161 if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
162 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
164 $port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
168 $server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
170 $server =
'127.0.0.1';
174 $wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
182 $listofmethods = array();
183 $listofmethods[
'mail'] =
'PHP mail function';
184 $listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
185 if (version_compare(phpversion(),
'7.0',
'>=')) {
186 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
190 $oauthservices = array();
192 foreach ($conf->global as $key => $val) {
193 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
194 $key = preg_replace(
'/^OAUTH_/',
'', $key);
195 $key = preg_replace(
'/_ID$/',
'', $key);
196 if (preg_match(
'/^.*-/', $key)) {
197 $name = preg_replace(
'/^.*-/',
'', $key);
199 $name = $langs->trans(
"NoName");
201 $provider = preg_replace(
'/-.*$/',
'', $key);
202 $provider = ucfirst(strtolower($provider));
204 $oauthservices[$key] = $name.
" (".$provider.
")";
208 if ($action ==
'edit') {
209 if ($conf->use_javascript_ajax) {
210 print
"\n".
'<script type="text/javascript">';
211 print
'jQuery(document).ready(function () {
212 function initfields()
214 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
216 console.log("I choose php mail mode");
217 jQuery(".drag").hide();
218 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
219 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
220 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
221 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
222 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
223 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
224 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
225 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
226 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
229 jQuery(".smtp_method").hide();
230 jQuery(".dkim").hide();
231 jQuery(".smtp_auth_method").hide();
235 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
236 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
237 jQuery("#smtp_server_mess").show();
238 jQuery("#smtp_port_mess").show();';
241 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
242 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
243 jQuery("#smtp_server_mess").hide();
244 jQuery("#smtp_port_mess").hide();';
248 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
250 console.log("I choose smtps mode");
251 jQuery(".drag").show();
252 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
253 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
254 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
255 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
256 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
257 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
258 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
259 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
260 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
261 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
262 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
263 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
264 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
265 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
266 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
267 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
268 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
269 jQuery("#MAIN_MAIL_SMTP_PORT").show();
270 jQuery("#smtp_server_mess").hide();
271 jQuery("#smtp_port_mess").hide();
272 jQuery(".smtp_method").show();
273 jQuery(".dkim").hide();
274 jQuery(".smtp_auth_method").show();
276 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
278 console.log("I choose swiftmailer mode");
279 jQuery(".drag").show();
280 jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.
');
281 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
282 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.
');
283 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
284 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.
');
285 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
286 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.
');
287 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
288 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
289 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
290 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
291 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
292 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
293 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
294 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
295 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
296 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
297 jQuery("#MAIN_MAIL_SMTP_PORT").show();
298 jQuery("#smtp_server_mess").hide();
299 jQuery("#smtp_port_mess").hide();
300 jQuery(".smtp_method").show();
301 jQuery(".dkim").show();
302 jQuery(".smtp_auth_method").show();
305 function change_smtp_auth_method() {
306 console.log(jQuery("#radio_pw").prop("checked"));
307 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
308 jQuery(".smtp_oauth_service").show();
309 jQuery(".smtp_pw").hide();
310 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
311 jQuery(".smtp_oauth_service").show();
312 jQuery(".smtp_pw").hide();
313 } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
314 jQuery(".smtp_oauth_service").hide();
315 jQuery(".smtp_pw").hide();
317 jQuery(".smtp_oauth_service").hide();
318 jQuery(".smtp_pw").show();
322 change_smtp_auth_method();
323 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
325 change_smtp_auth_method();
327 jQuery("#radio_pw, #radio_oauth").change(function() {
328 change_smtp_auth_method();
330 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
331 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
332 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
334 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
336 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
337 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
338 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
340 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
343 print
'</script>'.
"\n";
346 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
347 print
'<input type="hidden" name="token" value="'.newToken().
'">';
348 print
'<input type="hidden" name="action" value="update">';
352 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
358 print
'<table class="noborder centpercent">';
359 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
362 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
367 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
368 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 :
'').
'" />';
375 print
'<table class="noborder centpercent">';
376 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
379 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
382 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
383 print
$form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
385 $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
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">';
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 = (!empty($conf->global->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"><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 = (!empty($conf->global->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 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
463 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
464 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
465 print
' ';
466 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
467 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
470 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
471 print
$form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
472 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
478 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
479 $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
480 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
482 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
483 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
485 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
486 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
487 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
494 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
495 $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
496 print
'<tr class="drag drop oddeven smtp_pw"><td>';
497 print
$form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
500 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
501 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.
'" autocomplete="off">';
503 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
504 print
$form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
505 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.
'">';
511 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
512 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
515 if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
516 print
$form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
518 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
520 $text = $langs->trans(
"Undefined");
522 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
523 print
$form->textwithpicto($text, $htmltext, 1,
'superadmin');
524 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE.
'">';
529 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
530 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
531 if (function_exists(
'openssl_open')) {
532 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
534 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
537 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
542 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
543 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
544 if (function_exists(
'openssl_open')) {
545 print
$form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
547 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
550 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
555 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
556 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
557 if (function_exists(
'openssl_open')) {
558 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);
560 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
563 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
568 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
569 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
570 if (function_exists(
'openssl_open')) {
571 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);
573 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
576 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
581 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
582 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 :
'');
583 print
'"></td></tr>';
586 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
587 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 :
'');
588 print
'"></td></tr>';
591 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
592 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>';
599 print
'<table class="noborder centpercent">';
600 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
603 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
604 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>';
605 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 :
'');
606 print
'"></td></tr>';
610 $liste[
'user'] = $langs->trans(
'UserEmail');
611 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
613 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
614 print
$form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
618 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
619 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 :
'');
620 print
'"></td></tr>';
623 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
624 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 :
'');
625 print
'"></td></tr>';
628 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
629 print
$form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
636 print
$form->buttonsSaveCancel();
642 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
645 print
'<div class="div-table-responsive-no-min">';
646 print
'<table class="noborder centpercent">';
647 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
650 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
651 if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
656 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
658 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
663 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
672 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
675 print
'<div class="div-table-responsive-no-min">';
676 print
'<table class="noborder centpercent">';
677 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td></td></tr>';
680 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
683 $text = $langs->trans(
"Undefined").img_warning();
687 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
688 $textwarning = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
689 print
$form->textwithpicto(
'', $textwarning, 1,
'warning');
696 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></td></tr>';
698 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>';
704 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").
'</td><td><span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span></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>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT :
'').
'</td></tr>';
710 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
712 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
713 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
717 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
718 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.
'</td></tr>';
723 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*', $conf->global->MAIN_MAIL_SMTPS_PW).
'</td></tr>';
728 $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
730 $text = $langs->trans(
"Undefined").img_warning();
732 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
736 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
737 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
738 if (function_exists(
'openssl_open')) {
739 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
741 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
744 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
749 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
750 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
751 if (function_exists(
'openssl_open')) {
752 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
754 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
757 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
762 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
763 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
764 if (function_exists(
'openssl_open')) {
765 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
767 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
770 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
775 if ($conf->global->MAIN_MAIL_SENDMODE ==
'swiftmailer') {
777 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
778 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
779 if (function_exists(
'openssl_open')) {
782 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
785 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
790 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
791 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
795 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
796 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
800 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
801 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
808 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
809 $messagetoshow = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
810 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
811 $linktosetvar1 =
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
812 $linktosetvar2 =
'</a>';
813 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
814 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
815 print
info_admin($messagetoshow, 0, 0,
'warning');
820 print
'<div class="div-table-responsive-no-min">';
821 print
'<table class="noborder centpercent">';
822 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
825 $help =
img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
826 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ?ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined")).
' '.$help.
'</td>';
827 print
'<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
828 if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
830 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
837 $liste[
'user'] = $langs->trans(
'UserEmail');
838 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
839 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
840 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
841 $resql = $db->query($sql);
843 $num = $db->num_rows(
$resql);
846 $obj = $db->fetch_object(
$resql);
848 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
856 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
859 print $langs->trans(
'RobotEmail');
861 print $langs->trans(
'UserEmail');
865 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
867 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
869 $emailsenderprofile->fetch($id);
870 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
876 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
877 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
878 if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !
isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
884 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
886 if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
887 $listofemail = explode(
',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
889 foreach ($listofemail as $key => $val) {
896 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
906 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
'<div class="tabsAction">';
918 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
920 if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
922 if (function_exists(
'fsockopen') && $port && $server) {
923 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
926 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"FeatureNotAvailableOnLinux").
'">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
929 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
932 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
939 if (
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
951 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
954 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
961 if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
963 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
966 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
968 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
972 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
975 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
977 if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) {
979 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
984 if (!empty($companyemail) && function_exists(
'dns_get_record')) {
985 $arrayofemailparts = explode(
'@', $companyemail);
986 if (count($arrayofemailparts) == 2) {
987 $domain = $arrayofemailparts[1];
988 $dnsinfo = dns_get_record($domain, DNS_TXT);
991 if (!empty($dnsinfo) && is_array($dnsinfo)) {
992 foreach ($dnsinfo as $info) {
993 if (strpos($info[
'txt'],
'v=spf') !==
false) {
994 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $companyemail, $info[
'txt']);
1004 if ($action ==
'testconnect') {
1005 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1008 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1009 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
1010 $result = $mail->check_server_port($server, $port);
1012 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1014 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1017 $errormsg .=
' - '.$mail->error;
1026 if ($action ==
'test' || $action ==
'testhtml') {
1027 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1028 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1033 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1035 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1036 $formmail->fromname = (
GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1037 $formmail->frommail = (
GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1038 $formmail->fromid = $user->id;
1039 $formmail->fromalsorobot = 1;
1040 $formmail->fromtype = (
GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
1041 $formmail->withfromreadonly = 1;
1042 $formmail->withsubstit = 1;
1043 $formmail->withfrom = 1;
1044 $formmail->witherrorsto = 1;
1045 $formmail->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
1046 $formmail->withtocc = (
GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1047 $formmail->withtoccc = (
GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1048 $formmail->withtopic = (
GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1049 $formmail->withtopicreadonly = 0;
1050 $formmail->withfile = 2;
1051 $formmail->withbody = (
GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1052 $formmail->withbodyreadonly = 0;
1053 $formmail->withcancel = 1;
1054 $formmail->withdeliveryreceipt = 1;
1055 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1056 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1058 $formmail->substit = $substitutionarrayfortest;
1060 $formmail->param[
"action"] =
"send";
1061 $formmail->param[
"models"] =
"body";
1062 $formmail->param[
"mailid"] = 0;
1063 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1066 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1067 $formmail->clear_attached_files();
1070 print $formmail->get_form(
'addfile',
'removefile');
1075 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($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return 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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.