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 '__USER_LOGIN__' => $user->login,
52 '__USER_EMAIL__' => $user->email,
53 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
54 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
55 '__ID__' =>
'RecipientID',
57 '__LASTNAME__' =>
'RecipientLastname',
58 '__FIRSTNAME__' =>
'RecipientFirstname',
59 '__ADDRESS__'=>
'RecipientAddress',
60 '__ZIP__'=>
'RecipientZip',
61 '__TOWN_'=>
'RecipientTown',
62 '__COUNTRY__'=>
'RecipientCountry',
63 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
64 '__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" />',
74if ($action ==
'update' && !$cancel) {
75 if (!$error && !
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
77 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
82 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
87 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_MAILS",
GETPOST(
"MAIN_DISABLE_ALL_MAILS",
'int'),
'chaine', 0,
'', $conf->entity);
88 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
89 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOST(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
'int'),
'chaine', 0,
'', $conf->entity);
90 dolibarr_set_const($db,
'MAIN_MAIL_NO_WITH_TO_SELECTED',
GETPOST(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
'int'),
'chaine', 0,
'', $conf->entity);
94 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
95 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
96 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
99 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
100 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'chaine'),
'chaine', 0,
'', $conf->entity);
102 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
103 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'chaine'),
'chaine', 0,
'', $conf->entity);
106 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_STARTTLS",
GETPOST(
"MAIN_MAIL_EMAIL_STARTTLS",
'int'),
'chaine', 0,
'', $conf->entity);
107 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOST(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
'int'),
'chaine', 0,
'', $conf->entity);
109 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_ENABLED",
'int'),
'chaine', 0,
'', $conf->entity);
110 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
111 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
112 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
114 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
116 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
120 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
125if ($action ==
'disablephpmailwarning' && !$cancel) {
126 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1, 0, $conf->entity);
134$triggersendname =
'';
136$mode =
'emailfortest';
137$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
139include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
141if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
144if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
145 $action =
'testhtml';
154$form =
new Form($db);
157if (preg_match(
'/^win/i', PHP_OS)) {
160if (preg_match(
'/^mac/i', PHP_OS)) {
165 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
167$port =
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get(
'smtp_port');
171$server =
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get(
'SMTP');
173 $server =
'127.0.0.1';
177$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
178llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
185$listofmethods = array();
186$listofmethods[
'mail'] =
'PHP mail function';
187$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
188if (version_compare(phpversion(),
'7.0',
'>=')) {
189 $listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
193$oauthservices = array();
195foreach ($conf->global as $key => $val) {
196 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
197 $key = preg_replace(
'/^OAUTH_/',
'', $key);
198 $key = preg_replace(
'/_ID$/',
'', $key);
199 if (preg_match(
'/^.*-/', $key)) {
200 $name = preg_replace(
'/^.*-/',
'', $key);
202 $name = $langs->trans(
"NoName");
204 $provider = preg_replace(
'/-.*$/',
'', $key);
205 $provider = ucfirst(strtolower($provider));
207 $oauthservices[$key] = $name.
" (".$provider.
")";
211if ($action ==
'edit') {
212 if ($conf->use_javascript_ajax) {
213 print
"\n".
'<script type="text/javascript">';
214 print
'jQuery(document).ready(function () {
215 function initfields()
217 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
219 console.log("I choose php mail mode");
220 jQuery(".drag").hide();
221 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
222 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
223 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
224 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
225 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
226 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
227 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
228 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
229 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
230 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
231 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
232 jQuery(".smtp_method").hide();
233 jQuery(".dkim").hide();
234 jQuery(".smtp_auth_method").hide();
238 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
239 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
240 jQuery("#smtp_server_mess").show();
241 jQuery("#smtp_port_mess").show();';
244 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
245 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
246 jQuery("#smtp_server_mess").hide();
247 jQuery("#smtp_port_mess").hide();';
251 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
253 console.log("I choose smtps mode");
254 jQuery(".drag").show();
256 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
257 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
258 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
259 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
260 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
261 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
262 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
263 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
264 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
265 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
266 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
267 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
268 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
269 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
270 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
271 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
272 jQuery("#MAIN_MAIL_SMTP_PORT").show();
273 jQuery("#smtp_server_mess").hide();
274 jQuery("#smtp_port_mess").hide();
275 jQuery(".smtp_method").show();
276 jQuery(".dkim").hide();
277 jQuery(".smtp_auth_method").show();
279 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
281 console.log("I choose swiftmailer mode");
282 jQuery(".drag").show();
284 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
285 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
286 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
287 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
288 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
289 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
290 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
291 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
292 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
293 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
294 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
295 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
296 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
297 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
298 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
299 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
300 jQuery("#MAIN_MAIL_SMTP_PORT").show();
301 jQuery("#smtp_server_mess").hide();
302 jQuery("#smtp_port_mess").hide();
303 jQuery(".smtp_method").show();
304 jQuery(".dkim").show();
305 jQuery(".smtp_auth_method").show();
308 function change_smtp_auth_method() {
309 console.log(jQuery("#radio_pw").prop("checked"));
310 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
311 jQuery(".smtp_oauth_service").show();
312 jQuery(".smtp_pw").hide();
313 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
314 jQuery(".smtp_oauth_service").show();
315 jQuery(".smtp_pw").hide();
316 } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
317 jQuery(".smtp_oauth_service").hide();
318 jQuery(".smtp_pw").hide();
320 jQuery(".smtp_oauth_service").hide();
321 jQuery(".smtp_pw").show();
325 change_smtp_auth_method();
326 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
328 change_smtp_auth_method();
330 jQuery("#radio_pw, #radio_oauth").change(function() {
331 change_smtp_auth_method();
333 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
334 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
335 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
337 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
339 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
340 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
341 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
343 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
346 print
'</script>'.
"\n";
349 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
350 print
'<input type="hidden" name="token" value="'.newToken().
'">';
351 print
'<input type="hidden" name="action" value="update">';
355 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(
"Parameters").
'</td><td></td></tr>';
366 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
369 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
370 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
374 $text = $langs->trans(
"Undefined");
376 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
377 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
378 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
383 print
'<tr class="oddeven hideonmodemail">';
384 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
386 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
388 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
392 $mainserver = (
getDolGlobalString(
'MAIN_MAIL_SMTP_SERVER') ? $conf->global->MAIN_MAIL_SMTP_SERVER :
'');
393 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
395 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
397 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
401 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
402 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
403 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
404 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
405 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
407 $text = !empty($mainserver) ? $mainserver : $smtpserver;
408 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
409 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
410 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
417 print
'<tr class="oddeven hideonmodemail"><td>';
418 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
419 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
421 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
423 $mainport = (
getDolGlobalString(
'MAIN_MAIL_SMTP_PORT') ? $conf->global->MAIN_MAIL_SMTP_PORT :
'');
424 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
426 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
428 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
432 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
433 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
434 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
435 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
437 $text = (!empty($mainport) ? $mainport : $smtpport);
438 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
439 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
440 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
446 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
447 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
448 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
450 print
'<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE',
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
451 print
'<label for="radio_pw" >'.$langs->trans(
"UsePassword").
'</label>';
452 print
' ';
453 print
'<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString(
'MAIN_MAIL_SMTPS_AUTH_TYPE') ==
'XOAUTH2' ?
' checked' :
'').
'> ';
454 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
457 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
458 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
459 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
465 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
466 $mainstmpid = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID') ? $conf->global->MAIN_MAIL_SMTPS_ID :
'');
467 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
469 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
470 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
472 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
473 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1,
'superadmin');
474 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
481 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
482 $mainsmtppw = (
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW') ? $conf->global->MAIN_MAIL_SMTPS_PW :
'');
483 print
'<tr class="drag drop oddeven smtp_pw"><td>';
484 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
487 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
488 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
490 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
491 print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1,
'superadmin');
492 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
498 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
499 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
502 if (!isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
503 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
507 $text = $langs->trans(
"Undefined");
509 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
510 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
511 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
517 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
518 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
519 if (function_exists(
'openssl_open')) {
520 print $form->selectyesno(
'MAIN_MAIL_EMAIL_TLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_TLS') ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
522 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
525 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
530 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
531 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
532 if (function_exists(
'openssl_open')) {
533 print $form->selectyesno(
'MAIN_MAIL_EMAIL_STARTTLS', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS') ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
535 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
538 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
543 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
544 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
545 if (function_exists(
'openssl_open')) {
546 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);
548 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
551 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
556 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
557 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
558 if (function_exists(
'openssl_open')) {
559 print $form->selectyesno(
'MAIN_MAIL_EMAIL_DKIM_ENABLED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED') ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
561 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
564 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
569 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
570 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 :
'');
571 print
'"></td></tr>';
574 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
575 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 :
'');
576 print
'"></td></tr>';
579 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
580 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>';
589 print
'<table class="noborder centpercent">';
590 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"ParametersForTestEnvironment").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
593 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>';
594 print $form->selectyesno(
'MAIN_DISABLE_ALL_MAILS',
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS'), 1);
598 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
599 print
'<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO') ? $conf->global->MAIN_MAIL_FORCE_SENDTO :
'').
'" />';
608 print
'<table class="noborder centpercent">';
609 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
612 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
613 print
'<tr class="oddeven"><td class="fieldrequired">';
614 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
617 print
'<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="'.(getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM') ? $conf->global->MAIN_MAIL_EMAIL_FROM :
'');
618 print
'"></td></tr>';
622 $liste[
'user'] = $langs->trans(
'UserEmail');
623 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(!
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL') ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
625 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
626 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
630 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
631 print
'<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO') ? $conf->global->MAIN_MAIL_ERRORS_TO :
'');
632 print
'"></td></tr>';
635 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
636 print
'<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO') ? $conf->global->MAIN_MAIL_AUTOCOPY_TO :
'');
637 print
'"></td></tr>';
640 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
641 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
644 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
645 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
652 print $form->buttonsSaveCancel();
658 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
662 print
'<div class="div-table-responsive-no-min">';
663 print
'<table class="noborder centpercent">';
664 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
667 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
670 $text = $langs->trans(
"Undefined").img_warning();
675 $textwarning = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
676 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'warning',
'nomargintop');
685 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>';
693 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>';
697 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
699 $text = ($authtype ===
"LOGIN") ? $langs->trans(
"UsePassword") : ($authtype ===
"XOAUTH2" ? $langs->trans(
"UseOauth") :
'') ;
700 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
704 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
705 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
710 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
717 $text = $langs->trans(
"Undefined").img_warning();
719 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
726 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
727 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
728 if (function_exists(
'openssl_open')) {
729 print
yn($conf->global->MAIN_MAIL_EMAIL_TLS);
731 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
734 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
743 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
744 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
745 if (function_exists(
'openssl_open')) {
746 print
yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
748 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
760 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
761 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
762 if (function_exists(
'openssl_open')) {
763 print
yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
765 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
768 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
775 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
776 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
777 if (function_exists(
'openssl_open')) {
780 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
783 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
788 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
789 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
793 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
794 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
798 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
799 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
807 $messagetoshow = $langs->trans(
"WarningPHPMail").
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
808 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
809 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.newToken().
'">';
810 $linktosetvar2 =
'</a>';
811 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
812 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
814 print
info_admin($messagetoshow, 0, 0,
'warning nomargintop');
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(
"ParametersForTestEnvironment").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
825 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_MAILS").
'</td><td>'.
yn(
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS'));
833 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
838 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
851 print
'<div class="div-table-responsive-no-min">';
852 print
'<table class="noborder centpercent">';
853 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
856 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
857 print
'<tr class="oddeven"><td>';
858 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
864 } elseif (!
isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
871 $liste[
'user'] = $langs->trans(
'UserEmail');
872 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.(!
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL') ? $langs->trans(
"NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).
')';
873 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
874 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
875 $resql = $db->query($sql);
877 $num = $db->num_rows($resql);
880 $obj = $db->fetch_object($resql);
882 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
890 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
893 print $langs->trans(
'RobotEmail');
895 print $langs->trans(
'UserEmail');
899 $id = preg_replace(
'/senderprofile_/',
'',
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'));
901 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
903 $emailsenderprofile->fetch($id);
904 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
910 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
911 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
918 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
923 foreach ($listofemail as $key => $val) {
930 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
940 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>';
942 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>';
952 print
'<div class="tabsAction">';
954 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'">'.$langs->trans(
"Modify").
'</a>';
958 if (function_exists(
'fsockopen') && $port && $server) {
959 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
965 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
967 if (isModEnabled(
'fckeditor')) {
968 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
987 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
990 if (!in_array($action, array(
'testconnect',
'test',
'testhtml'))) {
999 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
1004 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
1011 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans(
"WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
1015 $text .= ($text ?
'<br><br>' :
'').
'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans(
"WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
1021 if (!empty($companyemail) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1022 $arrayofemailparts = explode(
'@', $companyemail);
1023 if (count($arrayofemailparts) == 2) {
1024 $domain = $arrayofemailparts[1];
1025 $dnsinfo = dns_get_record($domain, DNS_TXT);
1028 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1029 foreach ($dnsinfo as $info) {
1030 if (strpos($info[
'txt'],
'v=spf') !==
false) {
1031 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $companyemail, $info[
'txt']);
1037 if ($defaultnoreplyemail != $companyemail) {
1039 if (!empty($defaultnoreplyemail) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1040 $arrayofemailparts = explode(
'@', $defaultnoreplyemail);
1041 if (count($arrayofemailparts) == 2) {
1042 $domain = $arrayofemailparts[1];
1043 $dnsinfo = dns_get_record($domain, DNS_TXT);
1046 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1047 foreach ($dnsinfo as $info) {
1048 if (strpos($info[
'txt'],
'v=spf') !==
false) {
1049 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"ActualMailSPFRecordFound", $defaultnoreplyemail, $info[
'txt']);
1062 if ($action ==
'testconnect') {
1063 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1066 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1067 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0,
'',
'',
'',
'', $trackid, $sendcontext);
1068 $result = $mail->check_server_port($server, $port);
1070 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1072 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1075 $errormsg .=
' - '.$mail->error;
1084 if ($action ==
'test' || $action ==
'testhtml') {
1085 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1086 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1091 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1093 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1094 $formmail->fromname = (GETPOSTISSET(
'fromname') ?
GETPOST(
'fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1095 $formmail->frommail = (GETPOSTISSET(
'frommail') ?
GETPOST(
'frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
1096 $formmail->fromid = $user->id;
1097 $formmail->fromalsorobot = 1;
1098 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') : (
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE') ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE :
'user'));
1099 $formmail->withfromreadonly = 1;
1100 $formmail->withsubstit = 1;
1101 $formmail->withfrom = 1;
1102 $formmail->witherrorsto = 1;
1103 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->email ? $user->email : 1));
1104 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1105 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1106 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1107 $formmail->withtopicreadonly = 0;
1108 $formmail->withfile = 2;
1109 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1110 $formmail->withbodyreadonly = 0;
1111 $formmail->withcancel = 1;
1112 $formmail->withdeliveryreceipt = 1;
1113 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1114 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1116 $formmail->substit = $substitutionarrayfortest;
1118 $formmail->param[
"action"] =
"send";
1119 $formmail->param[
"models"] =
"body";
1120 $formmail->param[
"mailid"] = 0;
1121 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1124 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1125 $formmail->clear_attached_files();
1128 print $formmail->get_form(
'addfile',
'removefile');
1134 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_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 a 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', $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.