30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
45$langs->loadLangs(array(
"companies",
"products",
"admin",
"mails",
"other",
"errors"));
47$action =
GETPOST(
'action',
'aZ09');
48$cancel =
GETPOST(
'cancel',
'alpha');
56$usersignature = $user->signature;
58if ($action ==
'test' || ($action ==
'send' && $trackid ==
'test')) {
62$substitutionarrayfortest = array(
63 '__USER_LOGIN__' => $user->login,
64 '__USER_EMAIL__' => $user->email,
65 '__USER_FIRSTNAME__' => $user->firstname,
66 '__USER_LASTNAME__' => $user->lastname,
67 '__USER_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
68 '__SENDEREMAIL_SIGNATURE__' => (($user->signature && !
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? $usersignature :
''),
71 '__LASTNAME__' => $langs->trans(
"Lastname").
' ('.$langs->trans(
"MailRecipient").
')',
72 '__FIRSTNAME__' => $langs->trans(
"Firstname").
' ('.$langs->trans(
"MailRecipient").
')',
77 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
78 '__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" />',
89if ($action ==
'update' && !$cancel) {
90 if (!
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')) {
92 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MAIN_MAIL_EMAIL_FROM")),
null,
'errors');
97 setEventMessages($langs->trans(
"ErrorBadEMail",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml')),
null,
'errors');
103 dolibarr_set_const($db,
"MAIN_MAIL_FORCE_SENDTO",
GETPOST(
"MAIN_MAIL_FORCE_SENDTO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
104 dolibarr_set_const($db,
"MAIN_MAIL_ENABLED_USER_DEST_SELECT",
GETPOSTINT(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT"),
'chaine', 0,
'', $conf->entity);
109 dolibarr_set_const($db,
"MAIN_MAIL_SMTP_SERVER",
GETPOST(
"MAIN_MAIL_SMTP_SERVER",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
110 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_ID",
GETPOST(
"MAIN_MAIL_SMTPS_ID",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
111 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_PW")) {
112 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_PW",
GETPOST(
"MAIN_MAIL_SMTPS_PW",
'password'),
'chaine', 0,
'', $conf->entity);
114 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_AUTH_TYPE")) {
115 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_AUTH_TYPE",
GETPOST(
"MAIN_MAIL_SMTPS_AUTH_TYPE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
117 if (GETPOSTISSET(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
118 dolibarr_set_const($db,
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
GETPOST(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
122 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED",
GETPOSTINT(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED"),
'chaine', 0,
'', $conf->entity);
125 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
126 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
127 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
GETPOST(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
129 dolibarr_set_const($db,
"MAIN_MAIL_EMAIL_FROM",
GETPOST(
"MAIN_MAIL_EMAIL_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
130 dolibarr_set_const($db,
"MAIN_MAIL_ERRORS_TO",
GETPOST(
"MAIN_MAIL_ERRORS_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
131 dolibarr_set_const($db,
"MAIN_MAIL_AUTOCOPY_TO",
GETPOST(
"MAIN_MAIL_AUTOCOPY_TO",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
132 dolibarr_set_const($db,
'MAIN_MAIL_DEFAULT_FROMTYPE',
GETPOST(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
135 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
140if ($action ==
'disablephpmailwarning' && !$cancel) {
141 dolibarr_set_const($db,
'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1,
'chaine', 1,
'', $conf->entity);
149$triggersendname =
'';
151$mode =
'emailfortest';
152$trackid = ($action ==
'send' ?
GETPOST(
'trackid',
'aZ09') : $action);
153$sendcontext =
'standard';
154include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
156if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'test') {
159if ($action ==
'presend' &&
GETPOST(
'trackid',
'alphanohtml') ==
'testhtml') {
160 $action =
'testhtml';
168$form =
new Form($db);
172if (preg_match(
'/^win/i', PHP_OS)) {
175if (preg_match(
'/^mac/i', PHP_OS)) {
180 $conf->global->MAIN_MAIL_SENDMODE =
'mail';
183$port =
getDolGlobalInt(
'MAIN_MAIL_SMTP_PORT', (
int) ini_get(
'smtp_port'));
189 $server =
'127.0.0.1';
193$wikihelp =
'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
194llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-mails');
201$listofmethods = array();
202$listofmethods[
'mail'] =
'PHP mail function';
203$listofmethods[
'smtps'] =
'SMTP/SMTPS socket library';
204$listofmethods[
'swiftmailer'] =
'Swift Mailer socket library';
207$oauthservices = array();
209foreach ($conf->global as $key => $val) {
210 if (!empty($val) && preg_match(
'/^OAUTH_.*_ID$/', $key)) {
211 $key = preg_replace(
'/^OAUTH_/',
'', $key);
212 $key = preg_replace(
'/_ID$/',
'', $key);
213 if (preg_match(
'/^.*-/', $key)) {
214 $name = preg_replace(
'/^.*-/',
'', $key);
216 $name = $langs->trans(
"NoName");
218 $provider = preg_replace(
'/-.*$/',
'', $key);
219 $provider = ucfirst(strtolower($provider));
221 $oauthservices[$key] = $name.
" (".$provider.
")";
225if ($action ==
'edit') {
226 if ($conf->use_javascript_ajax) {
227 print
"\n".
'<script type="text/javascript">';
228 print
'jQuery(document).ready(function () {
229 function initfields()
231 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
233 console.log("I choose php mail mode");
234 jQuery(".drag").hide();
235 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
236 jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
237 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
238 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
239 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
240 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
241 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
242 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
243 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
244 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
245 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
246 jQuery(".smtp_method").hide();
247 jQuery(".dkim").hide();
248 jQuery(".smtp_auth_method").hide();
252 jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
253 jQuery("#MAIN_MAIL_SMTP_PORT").hide();
254 jQuery("#smtp_server_mess").show();
255 jQuery("#smtp_port_mess").show();';
258 jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
259 jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
260 jQuery("#smtp_server_mess").hide();
261 jQuery("#smtp_port_mess").hide();';
265 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
267 console.log("I choose smtps mode");
268 jQuery(".drag").show();
270 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
271 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
272 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
273 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
274 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
275 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
276 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
277 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
278 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
279 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
280 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
281 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
282 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
283 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
284 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
285 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
286 jQuery("#MAIN_MAIL_SMTP_PORT").show();
287 jQuery("#smtp_server_mess").hide();
288 jQuery("#smtp_port_mess").hide();
289 jQuery(".smtp_method").show();
290 jQuery(".dkim").hide();
291 jQuery(".smtp_auth_method").show();
293 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
295 console.log("I choose swiftmailer mode");
296 jQuery(".drag").show();
298 jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
299 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_STARTTLS').
');
300 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
301 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED').
');
302 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
303 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(' .
getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_ENABLED').
');
304 jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
305 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
306 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
307 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
308 jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
309 jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
310 jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
311 jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
312 jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
313 jQuery("#MAIN_MAIL_SMTP_SERVER").show();
314 jQuery("#MAIN_MAIL_SMTP_PORT").show();
315 jQuery("#smtp_server_mess").hide();
316 jQuery("#smtp_port_mess").hide();
317 jQuery(".smtp_method").show();
318 jQuery(".dkim").show();
319 jQuery(".smtp_auth_method").show();
322 function change_smtp_auth_method() {
323 console.log("Call smtp auth method");
324 if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') {
325 if (jQuery("#radio_oauth").prop("checked")) {
326 jQuery(".smtp_pw").hide();
327 jQuery(".smtp_oauth_service").show();
329 jQuery(".smtp_pw").show();
330 jQuery(".smtp_oauth_service").hide();
332 } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') {
333 if (jQuery("#radio_oauth").prop("checked")) {
334 jQuery(".smtp_pw").hide();
335 jQuery(".smtp_oauth_service").show();
337 jQuery(".smtp_pw").show();
338 jQuery(".smtp_oauth_service").hide();
341 jQuery(".smtp_pw").show();
342 jQuery(".smtp_oauth_service").hide();
346 change_smtp_auth_method();
347 jQuery("#MAIN_MAIL_SENDMODE").change(function() {
349 change_smtp_auth_method();
351 jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() {
352 change_smtp_auth_method();
354 jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
355 if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
356 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
358 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
360 jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
361 if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
362 jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
364 jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
367 print
'</script>'.
"\n";
370 print
'<form method="post" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
371 print
'<input type="hidden" name="token" value="'.newToken().
'">';
372 print
'<input type="hidden" name="action" value="update">';
376 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
383 print
'<div class="div-table-responsive-no-min">';
384 print
'<table class="noborder centpercent">';
385 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
388 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
391 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
392 print $form->selectarray(
'MAIN_MAIL_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'));
396 $text = $langs->trans(
"Undefined");
398 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
399 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
400 print
'<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail').
'">';
405 print
'<tr class="oddeven hideonmodemail">';
406 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
408 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
410 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
415 $smtpserver = ini_get(
'SMTP') ? ini_get(
'SMTP') : $langs->transnoentities(
"Undefined");
417 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
419 print $langs->trans(
"MAIN_MAIL_SMTP_SERVER", $smtpserver);
423 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
424 print
'<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'" autocomplete="off">';
425 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.
'">';
426 print
'<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
427 print
' <span class="opacitymedium smtp_method">'.$langs->trans(
"SeeLinkToOnlineDocumentation").
'</span>';
429 $text = !empty($mainserver) ? $mainserver : $smtpserver;
430 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
431 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
432 print
'<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.
'">';
439 print
'<tr class="oddeven hideonmodemail"><td>';
440 if (!$conf->use_javascript_ajax && $linuxlike &&
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail') ==
'mail') {
441 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
443 print
'<span class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
446 $smtpport = ini_get(
'smtp_port') ? ini_get(
'smtp_port') : $langs->transnoentities(
"Undefined");
448 print $langs->trans(
"MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
450 print $langs->trans(
"MAIN_MAIL_SMTP_PORT", $smtpport);
454 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
455 print
'<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.
'">';
456 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.
'">';
457 print
'<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans(
"SeeLocalSendMailSetup").
'</span>';
459 $text = (!empty($mainport) ? $mainport : $smtpport);
460 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
461 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
462 print
'<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.
'">';
468 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
469 print
'<tr class="oddeven smtp_auth_method"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>';
470 $vartosmtpstype =
'MAIN_MAIL_SMTPS_AUTH_TYPE';
471 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
473 print
'<input type="radio" id="radio_none" name="'.$vartosmtpstype.
'" value="NONE"'.(
getDolGlobalString($vartosmtpstype) ==
'NONE' ?
' checked' :
'').
'> ';
474 print
'<label for="radio_none" >'.$langs->trans(
"UseAUTHNONE").
'</label>';
476 print
'<input type="radio" id="radio_pw" name="'.$vartosmtpstype.
'" value="LOGIN"'.(
getDolGlobalString($vartosmtpstype,
'LOGIN') ==
'LOGIN' ?
' checked' :
'').
'> ';
477 print
'<label for="radio_pw" >'.$langs->trans(
"UseAUTHLOGIN").
'</label>';
479 print
'<input type="radio" id="radio_plain" name="'.$vartosmtpstype.
'" value="PLAIN"'.(
getDolGlobalString($vartosmtpstype) ==
'PLAIN' ?
' checked' :
'').
'> ';
480 print
'<label for="radio_plain" >'.$langs->trans(
"UseAUTHPLAIN").
'</label>';
482 print
'<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.
'" value="XOAUTH2"'.(
getDolGlobalString($vartosmtpstype) ==
'XOAUTH2' ?
' checked' :
'').(
isModEnabled(
'oauth') ?
'' :
' disabled').
'> ';
483 print
'<label for="radio_oauth" >'.$form->textwithpicto($langs->trans(
"UseOauth"), $langs->trans(
"OauthNotAvailableForAllAndHadToBeCreatedBefore")).
'</label>';
485 print
' <a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword=oauth">'.$langs->trans(
"EnableModuleX",
"OAuth").
'</a>';
487 print
' <a href="'.DOL_URL_ROOT.
'/admin/oauth.php">'.$langs->trans(
"SetupModuleX",
" OAuth").
'</a>';
491 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
492 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1,
'superadmin');
493 print
'<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.
'">';
499 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
501 print
'<tr class="drag drop oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>';
503 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
504 print
'<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.
'">';
506 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
507 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID'), $htmltext, 1,
'superadmin');
508 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.
'">';
515 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
517 print
'<tr class="drag drop oddeven smtp_pw"><td>';
518 print $form->textwithpicto($langs->trans(
"MAIN_MAIL_SMTPS_PW"), $langs->trans(
"WithGMailYouCanCreateADedicatedPassword"));
521 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
522 print
'<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'" autocomplete="off">';
524 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
525 print $form->textwithpicto(
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW'), $htmltext, 1,
'superadmin');
526 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars($mainsmtppw, ENT_COMPAT,
'UTF-8') .
'">';
532 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
533 print
'<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>';
536 if (!
isModEnabled(
'multicompany') || ($user->admin && !$user->entity)) {
537 print $form->selectarray(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices,
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE'));
541 $text = $langs->trans(
"Undefined");
543 $htmltext = $langs->trans(
"ContactSuperAdminForChange");
544 print $form->textwithpicto($text, $htmltext, 1,
'superadmin');
545 print
'<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_OAUTH_SERVICE').
'">';
551 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
552 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
553 if (function_exists(
'openssl_open')) {
556 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
559 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
564 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
565 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
566 if (function_exists(
'openssl_open')) {
569 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
572 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
577 print
'<tr class="oddeven hideonmodemail"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
578 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer')))) {
579 if (function_exists(
'openssl_open')) {
580 print $form->selectyesno(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED', (
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') ?
getDolGlobalString(
'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED') : 0), 1);
582 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
585 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
590 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
591 if (!empty($conf->use_javascript_ajax) || (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer')))) {
592 if (function_exists(
'openssl_open')) {
595 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
598 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
603 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
604 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');
605 print
'"></td></tr>';
608 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
609 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');
610 print
'"></td></tr>';
613 print
'<tr class="oddeven dkim"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
614 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').
'</textarea>';
622 print
'<div class="div-table-responsive-no-min">';
623 print
'<table class="noborder centpercent">';
624 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
627 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>';
628 print
'<input class="flat width300" name="MAIN_MAIL_FORCE_SENDTO" value="'.getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO').
'" />';
632 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
633 print
'<tr class="oddeven"><td class="fieldrequired">';
634 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
637 print
'<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM" value="'.getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM');
638 print
'"></td></tr>';
643 'label' => $langs->trans(
'UserEmail'),
644 'data-html' => $langs->trans(
'UserEmail')
647 'label' => $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')',
648 'data-html' => $langs->trans(
'CompanyEmail').
' <span class="opacitymedium">('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')</span>'
652 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td><td>';
653 print $form->selectarray(
'MAIN_MAIL_DEFAULT_FROMTYPE', $liste,
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
657 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
658 print
'<td><input class="flat width300" name="MAIN_MAIL_ERRORS_TO" value="'.getDolGlobalString(
'MAIN_MAIL_ERRORS_TO').
'">';
662 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
663 print
'<td><input class="flat width300" name="MAIN_MAIL_AUTOCOPY_TO" value="'.getDolGlobalString(
'MAIN_MAIL_AUTOCOPY_TO').
'">';
667 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ENABLED_USER_DEST_SELECT").
'</td><td>';
668 print $form->selectyesno(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT',
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
671 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_NO_WITH_TO_SELECTED").
'</td><td>';
672 print $form->selectyesno(
'MAIN_MAIL_NO_WITH_TO_SELECTED',
getDolGlobalString(
'MAIN_MAIL_NO_WITH_TO_SELECTED'), 1);
680 print $form->buttonsSaveCancel();
686 print
'<span class="opacitymedium">'.$langs->trans(
"EMailsDesc").
"</span><br>\n";
689 print $langs->trans(
"MAIN_DISABLE_ALL_MAILS");
690 if (!empty($conf->use_javascript_ajax)) {
691 print ajax_constantonoff(
'MAIN_DISABLE_ALL_MAILS', array(),
null, 0, 0, 1, 2, 0, 0,
'_red').
'</a>';
705 print
'<div class="div-table-responsive-no-min">';
706 print
'<table class="noborder centpercent">';
707 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"Parameters").
'</td><td></td></tr>';
710 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SENDMODE").
'</td><td>';
713 $text = $langs->trans(
"Undefined").img_warning();
719 $textwarning = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
720 print $form->textwithpicto(
'',
'<span class="small">'.$textwarning.
'</span>', 1,
'help',
'nomargintop');
729 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').
'</td></tr>';
737 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').
'</td></tr>';
741 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
744 if ($authtype ===
"NONE") {
745 $text = $langs->trans(
"None");
746 } elseif ($authtype ===
"LOGIN") {
747 $text = $langs->trans(
"UseAUTHLOGIN");
748 } elseif ($authtype ===
"PLAIN") {
749 $text = $langs->trans(
"UseAUTHPLAIN");
750 } elseif ($authtype ===
"XOAUTH2") {
751 $text = $langs->trans(
"UseOauth");
753 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_AUTH_TYPE").
'</td><td>'.$text.
'</td></tr>';
757 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
758 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_ID").
'</td><td>' .
getDolGlobalString(
'MAIN_MAIL_SMTPS_ID').
'</td></tr>';
763 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_PW").
'</td><td>'.preg_replace(
'/./',
'*',
getDolGlobalString(
'MAIN_MAIL_SMTPS_PW')).
'</td></tr>';
770 $text = $langs->trans(
"Undefined").img_warning();
772 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMTPS_OAUTH_SERVICE").
'</td><td>'.$text.
'</td></tr>';
779 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_TLS").
'</td><td>';
780 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
781 if (function_exists(
'openssl_open')) {
784 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
787 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
796 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_STARTTLS").
'</td><td>';
797 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
798 if (function_exists(
'openssl_open')) {
801 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
813 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").
'</td><td>';
814 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'smtps',
'swiftmailer'))) {
815 if (function_exists(
'openssl_open')) {
818 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
821 print
'<span class="opacitymedium">'.yn(0).
' ('.$langs->trans(
"NotSupported").
')</span>';
828 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_ENABLED").
'</td><td>';
829 if (in_array(
getDolGlobalString(
'MAIN_MAIL_SENDMODE',
'mail'), array(
'swiftmailer'))) {
830 if (function_exists(
'openssl_open')) {
833 print
yn(0).
' ('.$langs->trans(
"YourPHPDoesNotHaveSSLSupport").
')';
836 print
yn(0).
' ('.$langs->trans(
"NotSupported").
')';
841 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_DOMAIN").
'</td>';
842 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_DOMAIN');
846 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_SELECTOR").
'</td>';
847 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_SELECTOR');
851 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").
'</td>';
852 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
860 $messagetoshow = $langs->trans(
"WarningPHPMail", $listofmethods[
'mail'], $listofmethods[
'smtps']).
'<br>'.$langs->trans(
"WarningPHPMailA").
'<br>'.$langs->trans(
"WarningPHPMailB").
'<br>'.$langs->trans(
"WarningPHPMailC").
'<br><br>'.$langs->trans(
"WarningPHPMailD");
861 $messagetoshow .=
' '.$langs->trans(
"WarningPHPMailDbis",
'{s1}',
'{s2}');
862 $linktosetvar1 =
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=disablephpmailwarning&token='.
newToken().
'">';
863 $linktosetvar2 =
'</a>';
864 $messagetoshow = str_replace(
'{s1}', $linktosetvar1, $messagetoshow);
865 $messagetoshow = str_replace(
'{s2}', $linktosetvar2, $messagetoshow);
867 print
info_admin($messagetoshow, 0, 0,
'warning',
'nomargintop',
'',
'warning');
898 print
'<div class="div-table-responsive-no-min">';
899 print
'<table class="noborder centpercent">';
900 print
'<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans(
"OtherOptions").
'</td><td></td></tr>';
904 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_FORCE_SENDTO").
'</td><td>'.
getDolGlobalString(
'MAIN_MAIL_FORCE_SENDTO');
909 print
img_warning($langs->trans(
"RecipientEmailsWillBeReplacedWithThisValue"));
916 $help = $form->textwithpicto(
'', $langs->trans(
"EMailHelpMsgSPFDKIM"));
917 print
'<tr class="oddeven"><td>';
918 print $langs->trans(
"MAIN_MAIL_EMAIL_FROM", ini_get(
'sendmail_from') ? ini_get(
'sendmail_from') : $langs->transnoentities(
"Undefined"));
931 $liste[
'user'] = $langs->trans(
'UserEmail');
932 $liste[
'company'] = $langs->trans(
'CompanyEmail').
' ('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_MAIL', $langs->trans(
"NotDefined")).
')';
933 $sql =
'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
934 $sql .=
' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).
')';
935 $resql = $db->query($sql);
937 $num = $db->num_rows($resql);
940 $obj = $db->fetch_object($resql);
942 $liste[
'senderprofile_'.$obj->rowid] = $obj->label.
' <'.$obj->email.
'>';
950 print
'<tr class="oddeven"><td>'.$langs->trans(
'MAIN_MAIL_DEFAULT_FROMTYPE').
'</td>';
953 print $langs->trans(
'RobotEmail');
955 print $langs->trans(
'UserEmail');
961 include_once DOL_DOCUMENT_ROOT.
'/core/class/emailsenderprofile.class.php';
963 $emailsenderprofile->fetch($id);
964 print $emailsenderprofile->label.
' '.
dol_escape_htmltag(
'<'.$emailsenderprofile->email.
'>');
970 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_ERRORS_TO").
'</td>';
971 print
'<td>'.(getDolGlobalString(
'MAIN_MAIL_ERRORS_TO'));
978 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_AUTOCOPY_TO").
'</td>';
983 foreach ($listofemail as $key => $val) {
990 print
img_warning($langs->trans(
"ErrorBadEMail", $val));
1000 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>';
1002 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>';
1012 print
'<div class="tabsAction">';
1014 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'">'.$langs->trans(
"Modify").
'</a>';
1018 if (function_exists(
'fsockopen') ) {
1019 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testconnect&token='.
newToken().
'&date='.
dol_now().
'#formmailaftertstconnect">'.$langs->trans(
"DoTestServerAvailability").
'</a>';
1025 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSend").
'</a>';
1028 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=testhtml&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
"DoTestSendHTML").
'</a>';
1050 print
info_admin($langs->trans(
"SendmailOptionMayHurtBuggedMTA"));
1053 if (!in_array($action, array(
'testconnect',
'test',
'testhtml')) && !
getDolGlobalString(
'MAIN_DISABLE_ALL_MAILS')) {
1063 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1068 $text .= $langs->trans(
"WarningPHPMailSPFDMARC");
1075 $text .= $langs->trans(
"WarningPHPMailSPF",
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
1080 $arrayipstoshow = explode(
',',
getDolGlobalString(
'MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS'));
1081 foreach ($arrayipstoshow as $iptoshow) {
1083 if (preg_match(
'/^http/i', $iptoshow)) {
1084 $tmpresult =
getURLContent($iptoshow,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1085 if (!empty($tmpresult[
'content'])) {
1086 $iptoshow = $tmpresult[
'content'];
1091 $ipstoshow .= ($ipstoshow ?
', ' :
'').trim($iptoshow);
1094 $text .= ($text ?
'<br><br>' :
'').$langs->trans(
"WarningPHPMail2", $ipstoshow);
1100 $emailstotest = array();
1107 if (!empty($user->email)) {
1108 $emailstotest[$user->email] =
getDomainFromURL(preg_replace(
'/^.*@/',
'', $user->email), 1);
1110 $domainstotest = array();
1111 foreach ($emailstotest as $email => $domain) {
1112 if (empty($domainstotest[$domain])) {
1113 $domainstotest[$domain] = array($email => $email);
1115 $domainstotest[$domain][$email] = $email;
1120 if ($action ==
'testsetup') {
1121 foreach (array(
'SPF',
'DMARC') as $dnstype) {
1122 foreach ($domainstotest as $domaintotest => $listofemails) {
1125 if (!empty($domaintotest) && function_exists(
'dns_get_record') && !
getDolGlobalString(
'MAIN_DISABLE_DNS_GET_RECORD')) {
1126 $domain = $domaintotest;
1127 if ($dnstype ==
'DMARC') {
1128 $domain =
'_dmarc.'.$domain;
1132 $dnsinfo = @dns_get_record($domain, DNS_TXT, $authns);
1133 if ($dnsinfo ===
false) {
1134 $langs->load(
"errors");
1135 $text .= ($text ?
'<br>' :
'').$langs->trans(
"WarningDNSServerNotAvailable");
1139 if (!empty($dnsinfo) && is_array($dnsinfo)) {
1140 foreach ($dnsinfo as $info) {
1141 if (($dnstype ==
'SPF' && stripos($info[
'txt'],
'v=spf') !==
false)
1142 || ($dnstype ==
'DMARC' && stripos($info[
'txt'],
'v=dmarc') !==
false)) {
1144 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitylow">'.$info[
'txt'].
'</span>');
1148 if (!$foundforemail) {
1149 $text .= ($text ?
'<br>' :
'').
'- '.$langs->trans(
"ActualMailDNSRecordFound",
'<b>'.$dnstype.
'</b>',
'<b>'.implode(
', ', $listofemails).
'</b>',
'<span class="opacitymedium">'.$langs->transnoentitiesnoconv(
"None").
'</span>');
1155 print
info_admin($langs->trans(
"SPFAndDMARCInformation").
' :<br>'.$text, 0, 0,
'1',
'');
1158 print
img_picto(
'',
'info',
'class="pictofixedwidth"').
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=testsetup">'.$langs->trans(
"ClickHereToCheckSPFDMARCForSetup").
'...</a>';
1164 if ($action ==
'testconnect') {
1165 print
'<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
1168 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1169 $mail =
new CMailFile(
'',
'',
'',
'', array(), array(), array(),
'',
'', 0, 0,
'',
'',
'', $trackid, $sendcontext);
1170 $result = $mail->check_server_port($server, $port);
1172 print
'<div class="ok">'.$langs->trans(
"ServerAvailableOnIPOrPort", $server, $port).
'</div>';
1174 $errormsg = $langs->trans(
"ServerNotAvailableOnIPOrPort", $server, $port);
1177 $errormsg .=
' - '.$mail->error;
1186 if ($action ==
'test' || $action ==
'testhtml') {
1187 print
'<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
1188 print
load_fiche_titre($action ==
'testhtml' ? $langs->trans(
"DoTestSendHTML") : $langs->trans(
"DoTestSend"));
1193 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1195 $formmail->trackid = (($action ==
'testhtml') ?
"testhtml" :
"test");
1198 $formmail->fromid = $user->id;
1199 $formmail->fromalsorobot = 1;
1200 $formmail->fromtype = (GETPOSTISSET(
'fromtype') ?
GETPOST(
'fromtype',
'aZ09') :
getDolGlobalString(
'MAIN_MAIL_DEFAULT_FROMTYPE',
'user'));
1201 $formmail->withfromreadonly = 1;
1202 $formmail->withsubstit = 1;
1203 $formmail->withfrom = 1;
1204 $formmail->witherrorsto = 1;
1205 $formmail->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto',
'restricthtml') : ($user->
email ? $user->
email : 1));
1206 $formmail->withtocc = (GETPOSTISSET(
'sendtocc') ?
GETPOST(
'sendtocc',
'restricthtml') : 1);
1207 $formmail->withtoccc = (GETPOSTISSET(
'sendtoccc') ?
GETPOST(
'sendtoccc',
'restricthtml') : 1);
1208 $formmail->withtopic = (GETPOSTISSET(
'subject') ?
GETPOST(
'subject') : $langs->trans(
"Test"));
1209 $formmail->withtopicreadonly = 0;
1210 $formmail->withfile = 2;
1213 $formmail->withlayout =
'emailing';
1214 $formmail->withaiprompt = ($action ==
'testhtml' ?
'html' :
'text');
1216 $formmail->withbody = (GETPOSTISSET(
'message') ?
GETPOST(
'message',
'restricthtml') : ($action ==
'testhtml' ? $langs->transnoentities(
"PredefinedMailTestHtml") : $langs->transnoentities(
"PredefinedMailTest")));
1217 $formmail->withbodyreadonly = 0;
1218 $formmail->withcancel = 1;
1219 $formmail->withdeliveryreceipt = 1;
1220 $formmail->withfckeditor = ($action ==
'testhtml' ? 1 : 0);
1221 $formmail->ckeditortoolbar =
'dolibarr_mailings';
1223 $formmail->substit = $substitutionarrayfortest;
1225 $formmail->param[
"action"] =
"send";
1226 $formmail->param[
"models"] =
"body";
1227 $formmail->param[
"mailid"] = 0;
1228 $formmail->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
1231 if (
GETPOST(
"mode",
"aZ09") ==
'init') {
1232 $formmail->clear_attached_files();
1235 print $formmail->get_form(
'addfile',
'removefile');
1240 if (!empty($user->admin)) {
1242 print
'<span class="opacitymedium wordwrap small">'.$langs->trans(
"EMailsWillHaveMessageID").
': ';
$id
Support class for third parties, contacts, members, users or resources.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
email_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class for EmailSenderProfile.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array())
Function to get a content from an URL (use proxy if proxy defined).
dol_hash($chain, $type='0', $nosalt=0, $mode=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.