dolibarr/htdocs/admin/mails.php

1086 lines
52 KiB
PHP
Raw Normal View History

<?php
2020-01-20 18:46:13 +01:00
/* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Jonathan TISSEAU <jonathan.tisseau@86dev.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
2009-02-09 01:04:34 +01:00
* \file htdocs/admin/mails.php
* \brief Page to setup emails sending
2009-02-09 01:04:34 +01:00
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
2018-05-03 21:27:52 +02:00
$langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors"));
2020-09-16 19:39:50 +02:00
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$trackid = GETPOST('trackid');
2021-02-26 22:04:03 +01:00
if (!$user->admin) {
accessforbidden();
}
$usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html.
if ($action == 'test' || ($action == 'send' && $trackid = 'test')) {
$usersignature = dol_string_nohtmltag($usersignature, 2);
}
$substitutionarrayfortest = array(
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefinedtag&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-undefinedtag", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0" />',
'__USER_LOGIN__' => $user->login,
'__USER_EMAIL__' => $user->email,
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
'__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
'__ID__' => 'RecipientIdRecord',
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
'__LOGIN__' => $user->login,
'__LASTNAME__' => 'RecipientLastname',
'__FIRSTNAME__' => 'RecipientFirstname',
'__ADDRESS__'=> 'RecipientAddress',
'__ZIP__'=> 'RecipientZip',
'__TOWN_'=> 'RecipientTown',
'__COUNTRY__'=> 'RecipientCountry'
);
2011-06-09 00:08:02 +02:00
complete_substitutions_array($substitutionarrayfortest, $langs);
2012-01-02 17:36:14 +01:00
/*
2009-05-04 20:38:01 +02:00
* Actions
*/
2021-02-26 22:04:03 +01:00
if ($action == 'update' && !$cancel) {
if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors');
$action = 'edit';
}
if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) {
$error++;
setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors');
$action = 'edit';
}
if (!$error) {
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity);
// Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
2022-08-01 12:03:33 +02:00
if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
}
2022-08-01 12:03:33 +02:00
if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
2022-08-01 13:11:57 +02:00
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
2022-08-01 12:03:33 +02:00
}
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
// Content parameters
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
}
}
if ($action == 'disablephpmailwarning' && !$cancel) {
dolibarr_set_const($db, 'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP', 1, 'chaine', 1, 0, $conf->entity);
setEventMessages($langs->trans("WarningDisabled"), null, 'mesgs');
}
// Actions to send emails
$id = 0;
$actiontypecode = ''; // Not an event for agenda
$triggersendname = ''; // Disable triggers
$paramname = 'id';
$mode = 'emailfortest';
$trackid = ($action == 'send' ? GETPOST('trackid', 'aZ09') : $action);
$sendcontext = '';
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
2021-02-26 22:04:03 +01:00
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
$action = 'test';
}
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
$action = 'testhtml';
}
/*
2009-05-04 20:38:01 +02:00
* View
*/
2019-11-14 11:00:49 +01:00
$form = new Form($db);
$linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) {
$linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0;
}
2021-02-26 22:04:03 +01:00
if (empty($conf->global->MAIN_MAIL_SENDMODE)) {
$conf->global->MAIN_MAIL_SENDMODE = 'mail';
}
$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');
2021-02-26 22:04:03 +01:00
if (!$port) {
$port = 25;
}
$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP');
2021-02-26 22:04:03 +01:00
if (!$server) {
$server = '127.0.0.1';
}
$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
llxHeader('', $langs->trans("Setup"), $wikihelp);
print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
2017-10-13 12:02:26 +02:00
$head = email_admin_prepare_head();
// List of sending methods
$listofmethods = array();
$listofmethods['mail'] = 'PHP mail function';
$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
2021-02-26 22:04:03 +01:00
if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// List of oauth services
$oauthservices = array();
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$key = preg_replace('/^OAUTH_/', '', $key);
$key = preg_replace('/_ID$/', '', $key);
if (preg_match('/^.*-/', $key)) {
$name = preg_replace('/^.*-/', '', $key);
} else {
$name = $langs->trans("NoName");
}
$provider = preg_replace('/-.*$/', '', $key);
$provider = ucfirst(strtolower($provider));
$oauthservices[$key] = $name." (".$provider.")";
}
}
2021-02-26 22:04:03 +01:00
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
print "\n".'<script type="text/javascript">';
print 'jQuery(document).ready(function () {
function initfields()
{
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
{
2018-04-06 16:38:47 +02:00
console.log("I choose php mail mode");
jQuery(".drag").hide();
jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
jQuery("#MAIN_MAIL_EMAIL_TLS").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").prop("disabled", true);
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
2020-11-30 19:14:18 +01:00
jQuery(".smtp_method").hide();
2018-04-06 16:38:47 +02:00
jQuery(".dkim").hide();
jQuery(".smtp_auth_method").hide();
';
2021-02-26 22:04:03 +01:00
if ($linuxlike) {
2015-06-26 13:18:40 +02:00
print '
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_SMTP_SERVER").hide();
jQuery("#MAIN_MAIL_SMTP_PORT").hide();
jQuery("#smtp_server_mess").show();
jQuery("#smtp_port_mess").show();';
2020-05-21 09:35:30 +02:00
} else {
print '
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);
jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);
2020-11-30 19:14:18 +01:00
jQuery("#smtp_server_mess").hide();
2018-01-25 22:03:51 +01:00
jQuery("#smtp_port_mess").hide();';
}
print '
}
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
{
2018-04-06 16:38:47 +02:00
console.log("I choose smtps mode");
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.');
jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.');
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.');
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val(0);
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").hide();
jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").hide();
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").hide();
jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
2015-06-26 13:18:40 +02:00
jQuery("#MAIN_MAIL_SMTP_SERVER").show();
jQuery("#MAIN_MAIL_SMTP_PORT").show();
jQuery("#smtp_server_mess").hide();
2022-08-26 15:21:35 +02:00
jQuery("#smtp_port_mess").hide();
2020-11-30 19:14:18 +01:00
jQuery(".smtp_method").show();
2022-08-26 15:21:35 +02:00
jQuery(".dkim").hide();
jQuery(".smtp_auth_method").show();
2015-06-26 13:18:40 +02:00
}
2016-04-16 18:15:03 +02:00
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
{
2018-04-06 16:38:47 +02:00
console.log("I choose swiftmailer mode");
2016-04-16 18:15:03 +02:00
jQuery(".drag").show();
jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.');
jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val('.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.');
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val('.$conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED.');
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").removeAttr("disabled");
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").val('.$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED.');
jQuery("#MAIN_MAIL_EMAIL_DKIM_ENABLED").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").removeAttr("disabled");
jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").show();
jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").show();
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").show();
2016-04-16 18:15:03 +02:00
jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr("disabled");
jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr("disabled");
jQuery("#MAIN_MAIL_SMTP_SERVER").show();
jQuery("#MAIN_MAIL_SMTP_PORT").show();
jQuery("#smtp_server_mess").hide();
jQuery("#smtp_port_mess").hide();
2022-08-26 15:21:35 +02:00
jQuery(".smtp_method").show();
2018-04-06 16:38:47 +02:00
jQuery(".dkim").show();
2022-08-26 15:21:35 +02:00
jQuery(".smtp_auth_method").show();
2016-04-16 18:15:03 +02:00
}
}
function change_smtp_auth_method() {
console.log(jQuery("#radio_pw").prop("checked"));
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
2022-08-10 09:33:58 +02:00
} else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").hide();
} else {
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").show();
}
}
initfields();
change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE").change(function() {
initfields();
change_smtp_auth_method();
});
jQuery("#radio_pw, #radio_oauth").change(function() {
change_smtp_auth_method();
});
2018-01-25 22:03:51 +01:00
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
else
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
});
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
else
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0);
2018-01-25 22:03:51 +01:00
});
})';
print '</script>'."\n";
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
2009-05-04 20:38:01 +02:00
print '<input type="hidden" name="action" value="update">';
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'common', '', -1);
2019-11-14 11:00:49 +01:00
print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
2021-10-18 16:22:19 +02:00
print "<br><br>\n";
2009-05-04 20:38:01 +02:00
clearstatcache();
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
2009-05-04 20:38:01 +02:00
// Disable
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>';
2021-05-20 17:40:44 +02:00
print $form->selectyesno('MAIN_DISABLE_ALL_MAILS', getDolGlobalString('MAIN_DISABLE_ALL_MAILS'), 1);
2009-05-04 20:38:01 +02:00
print '</td></tr>';
2009-02-09 01:04:34 +01:00
// Force e-mail recipient
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>';
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 : '').'" />';
print '</td></tr>';
2009-02-09 01:04:34 +01:00
2020-09-12 15:39:14 +02:00
print '</table>';
2018-03-21 11:48:30 +01:00
2020-09-12 15:39:14 +02:00
print '<br>';
2018-03-21 11:48:30 +01:00
2020-09-12 15:39:14 +02:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
2009-05-04 20:38:01 +02:00
// Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
// SuperAdministrator access only
2021-02-26 22:04:03 +01:00
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
print $form->selectarray('MAIN_MAIL_SENDMODE', $listofmethods, getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'));
2020-05-21 09:35:30 +02:00
} else {
$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
2021-02-26 22:04:03 +01:00
if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail').'">';
2009-05-04 20:38:01 +02:00
}
print '</td></tr>';
2015-06-26 13:18:40 +02:00
// Host server
2020-11-30 19:14:18 +01:00
print '<tr class="oddeven">';
if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
2020-11-30 19:14:18 +01:00
print '<td>';
2009-05-04 20:38:01 +02:00
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
print '</td><td>';
2018-04-06 16:38:47 +02:00
print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
2020-11-30 19:14:18 +01:00
print '</td>';
2020-05-21 09:35:30 +02:00
} else {
2020-11-30 19:14:18 +01:00
print '<td>';
$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '');
$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
2021-02-26 22:04:03 +01:00
if ($linuxlike) {
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
}
2009-05-04 20:38:01 +02:00
print '</td><td>';
// SuperAdministrator access only
2022-08-27 19:39:58 +02:00
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
2020-11-30 19:14:18 +01:00
print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'" autocomplete="off">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">';
2018-04-06 16:38:47 +02:00
print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
2020-11-30 19:14:18 +01:00
print ' <span class="opacitymedium smtp_method">'.$langs->trans("SeeLinkToOnlineDocumentation").'</span>';
2020-05-21 09:35:30 +02:00
} else {
$text = !empty($mainserver) ? $mainserver : $smtpserver;
2009-05-04 20:38:01 +02:00
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
2012-07-10 11:45:38 +02:00
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'">';
2009-05-04 20:38:01 +02:00
}
2020-11-30 19:14:18 +01:00
print '</td>';
2009-05-04 20:38:01 +02:00
}
2020-11-30 19:14:18 +01:00
print '</tr>';
2009-05-04 20:38:01 +02:00
// Port
print '<tr class="oddeven"><td>';
if (!$conf->use_javascript_ajax && $linuxlike && getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
2009-05-04 20:38:01 +02:00
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
print '</td><td>';
2018-04-06 16:38:47 +02:00
print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
2020-05-21 09:35:30 +02:00
} else {
$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
2021-02-26 22:04:03 +01:00
if ($linuxlike) {
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
} else {
print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
}
2009-05-04 20:38:01 +02:00
print '</td><td>';
// SuperAdministrator access only
2022-08-27 19:39:58 +02:00
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">';
2018-04-06 16:38:47 +02:00
print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
2020-05-21 09:35:30 +02:00
} else {
$text = (!empty($mainport) ? $mainport : $smtpport);
2009-05-04 20:38:01 +02:00
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
2012-07-10 11:45:38 +02:00
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.'">';
2009-05-04 20:38:01 +02:00
}
}
print '</td></tr>';
2022-11-18 12:03:50 +01:00
// Auth mode
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
2022-11-18 12:03:50 +01:00
print '<tr class="oddeven smtp_auth_method"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
2022-08-27 19:39:58 +02:00
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
2022-11-18 12:03:50 +01:00
// Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case)
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN') == 'LOGIN' ? ' checked' : '').'> ';
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
print '&nbsp; &nbsp; &nbsp;';
print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') == 'XOAUTH2' ? ' checked' : '').'> ';
print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
2020-05-21 09:35:30 +02:00
} else {
2022-11-18 12:03:50 +01:00
$value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
2009-05-04 20:38:01 +02:00
$htmltext = $langs->trans("ContactSuperAdminForChange");
2022-11-18 12:03:50 +01:00
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.'">';
2009-05-04 20:38:01 +02:00
}
print '</td></tr>';
}
2009-05-04 20:38:01 +02:00
2022-11-18 12:03:50 +01:00
// ID
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
2022-11-18 12:03:50 +01:00
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
// SuperAdministrator access only
2022-08-27 19:39:58 +02:00
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
2022-11-18 12:03:50 +01:00
print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
2022-11-18 12:03:50 +01:00
print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$mainstmpid.'">';
}
print '</td></tr>';
}
2022-11-18 12:03:50 +01:00
2009-05-04 20:38:01 +02:00
// PW
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
print '<tr class="drag drop oddeven smtp_pw"><td>';
2019-11-25 21:02:26 +01:00
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
print '</td><td>';
2009-05-04 20:38:01 +02:00
// SuperAdministrator access only
2022-08-27 19:39:58 +02:00
if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.'" autocomplete="off">';
2020-05-21 09:35:30 +02:00
} else {
2009-05-04 20:38:01 +02:00
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW, $htmltext, 1, 'superadmin');
2012-07-10 11:45:38 +02:00
print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$mainsmtppw.'">';
2009-05-04 20:38:01 +02:00
}
print '</td></tr>';
}
// OAUTH service provider
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
print '<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
// SuperAdministrator access only
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
} else {
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE.'">';
}
print '</td></tr>';
}
// TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>';
// STARTTLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>';
// SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
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);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>';
2018-01-25 22:03:51 +01:00
// DKIM
2018-04-06 16:38:47 +02:00
print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer')))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
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);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
2018-01-25 22:03:51 +01:00
print '</td></tr>';
// DKIM Domain
print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
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 : '');
print '"></td></tr>';
2018-01-25 22:03:51 +01:00
// DKIM Selector
print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
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 : '');
print '"></td></tr>';
2018-01-25 22:03:51 +01:00
// DKIM PRIVATE KEY
print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
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>';
print '</td></tr>';
2018-01-25 22:03:51 +01:00
2020-09-12 15:39:14 +02:00
print '</table>';
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
2009-05-04 20:38:01 +02:00
// From
$help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
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>';
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 : '');
print '"></td></tr>';
// Default from type
$liste = array();
$liste['user'] = $langs->trans('UserEmail');
$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
2018-05-03 21:27:52 +02:00
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td><td>';
2021-05-20 17:40:44 +02:00
print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'), 0);
print '</td></tr>';
// From
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
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 : '');
print '"></td></tr>';
2009-05-04 20:38:01 +02:00
// Autocopy to
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
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 : '');
print '"></td></tr>';
2009-05-04 20:38:01 +02:00
2020-09-12 15:39:14 +02:00
// Add user to select destinaries list
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").'</td><td>';
2021-05-20 17:40:44 +02:00
print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1);
2020-09-12 15:39:14 +02:00
print '</td></tr>';
print '</table>';
2016-10-13 16:44:17 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
print $form->buttonsSaveCancel();
2009-05-04 20:38:01 +02:00
print '</form>';
2020-05-21 09:35:30 +02:00
} else {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'common', '', -1);
2019-05-21 21:52:04 +02:00
print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
2021-10-18 16:22:19 +02:00
print "<br><br>\n";
2018-06-13 17:03:46 +02:00
2021-01-26 11:19:13 +01:00
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
2009-05-04 20:38:01 +02:00
// Disable
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn(!empty($conf->global->MAIN_DISABLE_ALL_MAILS));
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
print img_warning($langs->trans("Disabled"));
}
2019-07-21 16:41:01 +02:00
print '</td></tr>';
2009-05-04 20:38:01 +02:00
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
// Force e-mail recipient
2021-03-19 17:58:01 +01:00
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
if (!empty(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
2021-02-26 22:04:03 +01:00
print img_warning($langs->trans("ErrorBadEMail"));
} else {
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
}
}
print '</td></tr>';
2019-07-21 16:41:01 +02:00
}
2009-05-04 20:38:01 +02:00
2020-09-12 15:39:14 +02:00
print '</table>';
2021-01-26 11:19:13 +01:00
print '</div>';
2020-09-12 15:39:14 +02:00
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
print '<br>';
2018-03-21 11:48:30 +01:00
2021-01-26 11:19:13 +01:00
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td></td></tr>';
2020-09-12 15:39:14 +02:00
// Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
$text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail')];
2021-02-26 22:04:03 +01:00
if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print $text;
2009-05-04 20:38:01 +02:00
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
$textwarning = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
print $form->textwithpicto('', $textwarning, 1, 'warning');
}
2009-05-04 20:38:01 +02:00
print '</td></tr>';
2009-05-04 20:38:01 +02:00
// Host server
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else {
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>';
}
2009-05-04 20:38:01 +02:00
// Port
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else {
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>';
}
2009-05-04 20:38:01 +02:00
// AUTH method
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
2022-08-10 09:33:58 +02:00
$authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
$text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
}
2022-11-18 12:03:50 +01:00
// SMTPS ID
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>';
}
// SMTPS PW
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>';
}
// SMTPS oauth service
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
}
// TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
print yn($conf->global->MAIN_MAIL_EMAIL_TLS);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>';
// STARTTLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
print '</td></tr>';
2018-01-25 22:03:51 +01:00
// SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED);
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
}
2018-04-06 16:38:47 +02:00
print '</td></tr>';
2018-01-25 22:03:51 +01:00
2021-02-26 22:04:03 +01:00
if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') {
// DKIM
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('swiftmailer'))) {
2021-02-26 22:04:03 +01:00
if (function_exists('openssl_open')) {
2022-03-10 17:24:54 +01:00
print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_DKIM_ENABLED'));
2021-02-26 22:04:03 +01:00
} else {
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
}
} else {
print yn(0).' ('.$langs->trans("NotSupported").')';
}
print '</td></tr>';
// Domain
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
2021-03-20 13:07:46 +01:00
print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_DOMAIN');
print '</td></tr>';
// Selector
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
2021-03-20 13:07:46 +01:00
print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_SELECTOR');
print '</td></tr>';
// PRIVATE KEY
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
2021-03-20 13:07:46 +01:00
print '<td>'.getDolGlobalString('MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY');
print '</td></tr>';
}
2018-01-25 22:03:51 +01:00
print '</table>';
2021-01-26 11:19:13 +01:00
print '</div>';
2018-01-25 22:03:51 +01:00
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
$messagetoshow = $langs->trans("WarningPHPMail").'<br>'.$langs->trans("WarningPHPMailA").'<br>'.$langs->trans("WarningPHPMailB").'<br>'.$langs->trans("WarningPHPMailC").'<br><br>'.$langs->trans("WarningPHPMailD");
$messagetoshow .= ' '.$langs->trans("WarningPHPMailDbis", '{s1}', '{s2}');
$linktosetvar1 = '<a href="'.$_SERVER["PHP_SELF"].'?action=disablephpmailwarning&token='.newToken().'">';
$linktosetvar2 = '</a>';
$messagetoshow = str_replace('{s1}', $linktosetvar1, $messagetoshow);
$messagetoshow = str_replace('{s2}', $linktosetvar2, $messagetoshow);
print info_admin($messagetoshow, 0, 0, 'warning');
}
2020-09-12 15:39:14 +02:00
print '<br>';
2020-09-12 15:39:14 +02:00
2021-01-26 11:19:13 +01:00
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
2020-09-12 15:39:14 +02:00
// From
$help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.'</td>';
print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
2021-02-26 22:04:03 +01:00
if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) {
print img_warning($langs->trans("Mandatory"));
} elseif (!isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) {
print img_warning($langs->trans("ErrorBadEMail"));
}
print '</td></tr>';
// Default from type
$liste = array();
$liste['user'] = $langs->trans('UserEmail');
$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
2021-04-26 19:12:23 +02:00
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
$resql = $db->query($sql);
2021-02-26 22:04:03 +01:00
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
2021-02-26 22:04:03 +01:00
while ($i < $num) {
$obj = $db->fetch_object($resql);
2021-02-26 22:04:03 +01:00
if ($obj) {
$liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
}
$i++;
}
2021-02-26 22:04:03 +01:00
} else {
dol_print_error($db);
}
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
print '<td>';
2021-04-23 18:01:11 +02:00
if (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'robot') {
print $langs->trans('RobotEmail');
2021-04-23 18:01:11 +02:00
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'user') {
print $langs->trans('UserEmail');
2021-04-23 18:01:11 +02:00
} elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') {
print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>');
} else {
2021-04-23 18:01:11 +02:00
$id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE'));
if ($id > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php';
$emailsenderprofile = new EmailSenderProfile($db);
$emailsenderprofile->fetch($id);
print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>');
}
}
print '</td></tr>';
// Errors To
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
2021-04-23 18:01:11 +02:00
print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) {
print img_warning($langs->trans("ErrorBadEMail"));
}
print '</td></tr>';
// Autocopy to
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
print '<td>';
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
$listofemail = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
$i = 0;
foreach ($listofemail as $key => $val) {
if ($i) {
print ', ';
}
$val = trim($val);
print $val;
if (!isValidEmail($val, 0, 1)) {
print img_warning($langs->trans("ErrorBadEMail", $val));
}
$i++;
2021-02-26 22:04:03 +01:00
}
} else {
print '&nbsp;';
}
print '</td></tr>';
//Add user to select destinaries list
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>';
print '</table>';
2021-01-26 11:19:13 +01:00
print '</div>';
2012-07-10 11:45:38 +02:00
}
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2018-02-04 10:55:09 +01:00
// Actions button
2009-05-04 20:38:01 +02:00
print '<div class="tabsAction">';
2021-09-27 12:24:01 +02:00
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') != 'mail' || !$linuxlike) {
2021-02-26 22:04:03 +01:00
if (function_exists('fsockopen') && $port && $server) {
2021-01-28 19:45:52 +01:00
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
}
} else {
2023-04-03 23:00:30 +02:00
//print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
}
2021-01-28 19:45:52 +01:00
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>';
2022-08-27 19:39:58 +02:00
if (isModEnabled('fckeditor')) {
2021-01-28 19:45:52 +01:00
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>';
}
}
2009-05-04 20:38:01 +02:00
print '</div>';
2009-02-09 01:04:34 +01:00
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) {
2018-02-04 10:55:09 +01:00
/*
// Warning 1
if ($linuxlike)
{
$sendmailoption=ini_get('mail.force_extra_parameters');
if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
{
print info_admin($langs->trans("SendmailOptionNotComplete"));
}
}*/
// Warning 2
print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
}
2021-02-26 22:04:03 +01:00
if (!in_array($action, array('testconnect', 'test', 'testhtml'))) {
2018-02-16 23:49:08 +01:00
$text = '';
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
2020-09-12 15:39:14 +02:00
//$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS
2018-02-16 23:49:08 +01:00
}
2020-01-29 13:10:16 +01:00
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail') {
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) {
2020-11-11 13:20:17 +01:00
// List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com'
2021-10-27 11:15:26 +02:00
$text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD);
} else {
// MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'.
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
// List of IP show as record to add in SPF if we use the mail method
2021-10-27 11:15:26 +02:00
$text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
}
2020-01-29 13:10:16 +01:00
}
} else {
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) {
2020-11-11 13:20:17 +01:00
// List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]'
// TODO Add a key to allow to show the IP/name of server detected dynamically
2021-10-27 11:15:26 +02:00
$text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS -->'.$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
2020-01-29 13:10:16 +01:00
}
2021-02-26 22:04:03 +01:00
if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server.
2020-11-11 13:20:17 +01:00
// List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com'
2021-10-27 11:15:26 +02:00
$text .= ($text ? '<br><br>' : '').'<!-- MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD -->'.$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD);
2020-01-29 13:10:16 +01:00
}
2018-02-16 23:49:08 +01:00
}
2021-10-31 18:43:11 +01:00
$companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL');
$dnsinfo = false;
2021-11-01 02:35:15 +01:00
if (!empty($companyemail) && function_exists('dns_get_record')) {
2021-11-07 18:59:11 +01:00
$arrayofemailparts = explode('@', $companyemail);
if (count($arrayofemailparts) == 2) {
$domain = $arrayofemailparts[1];
$dnsinfo = dns_get_record($domain, DNS_TXT);
}
2021-10-31 18:43:11 +01:00
}
if (!empty($dnsinfo) && is_array($dnsinfo)) {
foreach ($dnsinfo as $info) {
2021-11-01 02:35:15 +01:00
if (strpos($info['txt'], 'v=spf') !== false) {
2022-07-25 00:36:38 +02:00
$text .= ($text ? '<br><br>' : '').$langs->trans("ActualMailSPFRecordFound", $companyemail, $info['txt']);
2021-10-31 18:43:11 +01:00
}
}
}
2021-02-26 22:04:03 +01:00
if ($text) {
print info_admin($text);
}
}
// Run the test to connect
2021-02-26 22:04:03 +01:00
if ($action == 'testconnect') {
2021-01-28 19:45:52 +01:00
print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
2009-05-04 20:38:01 +02:00
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port);
2021-02-26 22:04:03 +01:00
if ($result) {
print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
} else {
$errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
if ($mail->error) {
$errormsg .= ' - '.$mail->error;
}
2015-10-28 19:28:18 +01:00
setEventMessages($errormsg, null, 'errors');
2009-05-04 20:38:01 +02:00
}
print '<br>';
}
// Show email send test form
2021-02-26 22:04:03 +01:00
if ($action == 'test' || $action == 'testhtml') {
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
2009-05-04 20:38:01 +02:00
2023-04-03 23:00:30 +02:00
print dol_get_fiche_head(array(), '', '', -1);
2017-07-14 02:07:01 +02:00
2009-05-04 20:38:01 +02:00
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
2009-05-04 20:38:01 +02:00
$formmail = new FormMail($db);
$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
2022-02-22 23:44:56 +01:00
$formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->fromid = $user->id;
$formmail->fromalsorobot = 1;
$formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
$formmail->withfromreadonly = 1;
$formmail->withsubstit = 1;
$formmail->withfrom = 1;
$formmail->witherrorsto = 1;
2022-02-22 23:44:56 +01:00
$formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
$formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
$formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
2020-11-30 14:47:07 +01:00
$formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
$formmail->withtopicreadonly = 0;
$formmail->withfile = 2;
2020-11-30 14:47:07 +01:00
$formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
$formmail->withbodyreadonly = 0;
$formmail->withcancel = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
$formmail->ckeditortoolbar = 'dolibarr_mailings';
2009-05-04 20:38:01 +02:00
// Tableau des substitutions
$formmail->substit = $substitutionarrayfortest;
2009-05-04 20:38:01 +02:00
// Tableau des parametres complementaires du post
$formmail->param["action"] = "send";
$formmail->param["models"] = "body";
$formmail->param["mailid"] = 0;
$formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
2009-05-04 20:38:01 +02:00
// Init list of files
2021-02-26 22:04:03 +01:00
if (GETPOST("mode", "aZ09") == 'init') {
2009-05-04 20:38:01 +02:00
$formmail->clear_attached_files();
}
2009-02-09 01:04:34 +01:00
print $formmail->get_form('addfile', 'removefile');
2009-02-09 01:04:34 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
// References
2023-04-03 23:00:30 +02:00
print '<br><br>';
print '<span class="opacitymedium">'.$langs->trans("EMailsWillHaveMessageID").': ';
print dol_escape_htmltag('<timestamp.*@'.dol_getprefix('email').'>');
print '</span>';
}
}
2018-07-28 18:03:14 +02:00
// End of page
llxFooter();
2012-01-02 17:36:14 +01:00
$db->close();