2007-06-08 01:29:53 +02:00
< ? 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 >
2013-08-20 09:28:23 +02:00
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
2016-03-16 02:09:55 +01:00
* Copyright ( C ) 2016 Jonathan TISSEAU < jonathan . tisseau @ 86 dev . fr >
2007-06-08 01:29:53 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2007-06-08 01:29:53 +02:00
* ( 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 />.
2007-06-08 01:29:53 +02:00
*/
/**
2009-02-09 01:04:34 +01:00
* \file htdocs / admin / mails . php
2010-08-28 12:55:11 +02:00
* \brief Page to setup emails sending
2009-02-09 01:04:34 +01:00
*/
2007-06-08 01:29:53 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2007-06-08 01:29:53 +02:00
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 " ));
2007-06-08 01:29:53 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-10-14 12:21:31 +02:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
2014-06-21 01:26:41 +02:00
2021-02-26 22:04:03 +01:00
if ( ! $user -> admin ) {
accessforbidden ();
}
2007-06-08 01:29:53 +02:00
2019-11-28 12:36:20 +01:00
$usersignature = $user -> signature ;
2014-06-21 01:26:41 +02:00
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
2020-05-28 11:41:48 +02:00
2021-02-26 22:04:03 +01:00
if ( $action == 'test' || $action == 'send' ) {
2020-05-28 11:41:48 +02:00
$usersignature = dol_string_nohtmltag ( $usersignature , 2 );
2014-06-21 01:26:41 +02:00
}
2019-11-28 12:36:20 +01:00
$substitutionarrayfortest = array (
2020-05-28 11:41:48 +02:00
'__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT ,
'__ID__' => 'RecipientIdRecord' ,
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
2021-04-12 16:03:56 +02:00
'__CHECK_READ__' => ( is_object ( $object ) && ! empty ( $object -> thirdparty ) && is_object ( $object -> thirdparty )) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object -> thirdparty -> tag . '&securitykey=' . urlencode ( $conf -> global -> MAILING_EMAIL_UNSUBSCRIBE_KEY ) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '' ,
2020-05-28 11:41:48 +02:00
'__USER_SIGNATURE__' => (( $user -> signature && empty ( $conf -> global -> MAIN_MAIL_DO_NOT_USE_SIGN )) ? $usersignature : '' ), // Done into actions_sendmails
'__LOGIN__' => 'RecipientLogin' ,
'__LASTNAME__' => 'RecipientLastname' ,
'__FIRSTNAME__' => 'RecipientFirstname' ,
'__ADDRESS__' => 'RecipientAddress' ,
'__ZIP__' => 'RecipientZip' ,
'__TOWN_' => 'RecipientTown' ,
'__COUNTRY__' => 'RecipientCountry'
2007-06-16 18:59:52 +02:00
);
2011-06-09 00:08:02 +02:00
complete_substitutions_array ( $substitutionarrayfortest , $langs );
2007-06-16 18:59:52 +02:00
2012-01-02 17:36:14 +01:00
2007-06-16 18:59:52 +02:00
/*
2009-05-04 20:38:01 +02:00
* Actions
*/
2007-06-08 01:29:53 +02:00
2021-02-26 22:04:03 +01:00
if ( $action == 'update' && ! $cancel ) {
2020-10-31 14:32:18 +01:00
if ( ! $error && ! GETPOST ( " MAIN_MAIL_EMAIL_FROM " , 'alphanohtml' )) {
2020-10-14 12:21:31 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " MAIN_MAIL_EMAIL_FROM " )), null , 'errors' );
$action = 'edit' ;
}
2020-10-31 14:32:18 +01:00
if ( ! $error && ! isValidEmail ( GETPOST ( " MAIN_MAIL_EMAIL_FROM " , 'alphanohtml' ))) {
2020-10-14 12:21:31 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorBadEMail " , GETPOST ( " MAIN_MAIL_EMAIL_FROM " , 'alphanohtml' )), null , 'errors' );
$action = 'edit' ;
}
2020-10-31 14:32:18 +01:00
if ( ! $error ) {
2020-10-14 12:21:31 +02:00
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 );
dolibarr_set_const ( $db , " MAIN_MAIL_SMTPS_PW " , GETPOST ( " MAIN_MAIL_SMTPS_PW " , 'none' ), 'chaine' , 0 , '' , $conf -> entity );
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 ;
}
2007-06-08 01:29:53 +02:00
}
2008-05-23 21:43:28 +02:00
2016-09-26 14:08:14 +02:00
// Actions to send emails
2019-11-28 12:36:20 +01:00
$id = 0 ;
$actiontypecode = '' ; // Not an event for agenda
2019-12-02 09:38:16 +01:00
$triggersendname = '' ; // Disable triggers
2019-11-28 12:36:20 +01:00
$paramname = 'id' ;
$mode = 'emailfortest' ;
$trackid = (( $action == 'testhtml' ) ? " testhtml " : " test " );
2020-04-10 10:59:32 +02:00
$sendcontext = '' ;
2016-09-26 14:08:14 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2010-01-13 11:30:33 +01:00
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' ;
}
2007-06-16 18:59:52 +02:00
2008-04-17 01:11:45 +02:00
2007-06-16 18:59:52 +02:00
/*
2009-05-04 20:38:01 +02:00
* View
*/
2007-06-08 01:29:53 +02:00
2019-11-14 11:00:49 +01:00
$form = new Form ( $db );
2019-11-28 12:36:20 +01:00
$linuxlike = 1 ;
2020-12-19 15:28:58 +01:00
if ( preg_match ( '/^win/i' , PHP_OS )) {
$linuxlike = 0 ;
}
if ( preg_match ( '/^mac/i' , PHP_OS )) {
$linuxlike = 0 ;
}
2008-09-10 12:12:37 +02:00
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> global -> MAIN_MAIL_SENDMODE )) {
$conf -> global -> MAIN_MAIL_SENDMODE = 'mail' ;
}
2019-11-28 12:36:20 +01:00
$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 ;
}
2019-11-28 12:36:20 +01:00
$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' ;
}
2008-04-17 01:11:45 +02:00
2019-11-28 12:36:20 +01:00
$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " Setup " ), $wikihelp );
2007-06-08 01:29:53 +02:00
2019-01-27 11:55:16 +01:00
print load_fiche_titre ( $langs -> trans ( " EMailsSetup " ), '' , 'title_setup' );
2007-06-08 01:29:53 +02:00
2017-10-13 12:02:26 +02:00
$head = email_admin_prepare_head ();
2007-06-08 01:29:53 +02:00
2009-11-01 15:16:30 +01:00
// List of sending methods
2019-11-28 12:36:20 +01:00
$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' ;
}
2009-11-01 15:16:30 +01:00
2007-06-08 01:29:53 +02:00
2021-02-26 22:04:03 +01:00
if ( $action == 'edit' ) {
if ( $conf -> use_javascript_ajax ) {
2011-09-14 23:50:18 +02:00
print " \n " . '<script type="text/javascript" language="javascript">' ;
print ' jQuery ( document ) . ready ( function () {
2011-03-25 23:07:14 +01:00
function initfields ()
{
if ( jQuery ( " #MAIN_MAIL_SENDMODE " ) . val () == \ ' mail\ ' )
{
2018-04-06 16:38:47 +02:00
console . log ( " I choose php mail mode " );
2011-03-25 23:07:14 +01:00
jQuery ( " .drag " ) . hide ();
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val ( 0 );
2015-05-12 14:47:33 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . prop ( " disabled " , true );
2016-03-16 02:09:55 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val ( 0 );
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . prop ( " disabled " , true );
2020-09-08 14:48:50 +02:00
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 ();
2011-03-25 23:07:14 +01:00
' ;
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 {
2020-10-31 14:32:18 +01:00
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 (); ' ;
2020-10-31 14:32:18 +01:00
}
print '
2011-03-25 23:07:14 +01:00
}
if ( jQuery ( " #MAIN_MAIL_SENDMODE " ) . val () == \ ' smtps\ ' )
{
2018-04-06 16:38:47 +02:00
console . log ( " I choose smtps mode " );
2011-03-25 23:07:14 +01:00
jQuery ( " .drag " ) . show ();
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val ( '.$conf->global->MAIN_MAIL_EMAIL_TLS.' );
2015-05-12 14:47:33 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . removeAttr ( " disabled " );
2016-03-16 02:09:55 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val ( '.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.' );
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . removeAttr ( " disabled " );
2020-09-08 14:48:50 +02:00
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 ();
2015-05-12 14:47:33 +02:00
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 ();
jQuery ( " #smtp_port_mess " ) . hide ();
2020-11-30 19:14:18 +01:00
jQuery ( " .smtp_method " ) . show ();
jQuery ( " .dkim " ) . hide ();
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 " );
2020-09-08 14:48:50 +02:00
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 ();
2020-11-30 19:14:18 +01:00
jQuery ( " .smtp_method " ) . show ();
2018-04-06 16:38:47 +02:00
jQuery ( " .dkim " ) . show ();
2016-04-16 18:15:03 +02:00
}
2011-03-25 23:07:14 +01:00
}
initfields ();
jQuery ( " #MAIN_MAIL_SENDMODE " ) . change ( function () {
initfields ();
});
2018-01-25 22:03:51 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . change ( function () {
2020-09-08 14:48:50 +02:00
if ( jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val () == 1 )
2016-03-16 02:09:55 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val ( 0 );
2020-09-08 14:48:50 +02:00
else
jQuery ( " #MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . val ( 0 );
2016-03-16 02:09:55 +01:00
});
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . change ( function () {
2020-09-08 14:48:50 +02:00
if ( jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val () == 1 )
2016-03-16 02:09:55 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val ( 0 );
2020-09-08 14:48:50 +02:00
else
jQuery ( " #MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . val ( 0 );
2018-01-25 22:03:51 +01:00
});
2011-03-25 23:07:14 +01:00
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
2011-09-14 23:50:18 +02:00
}
2011-03-25 23:07:14 +01:00
2009-05-04 16:58:40 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2009-05-04 20:38:01 +02:00
print '<input type="hidden" name="action" value="update">' ;
2007-06-08 01:29:53 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'common' , '' , - 1 );
2017-06-11 11:40:01 +02:00
2019-11-14 11:00:49 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " EMailsDesc " ) . " </span><br> \n " ;
2017-02-12 18:13:49 +01:00
print " <br> \n " ;
2017-06-11 11:40:01 +02:00
2009-05-04 20:38:01 +02:00
clearstatcache ();
2007-06-08 01:29:53 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2017-08-24 02:02:00 +02:00
print '<tr class="liste_titre"><td class="titlefieldmiddle">' . $langs -> trans ( " Parameter " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td></tr>' ;
2007-06-08 01:29:53 +02:00
2009-05-04 20:38:01 +02:00
// Disable
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_DISABLE_ALL_MAILS " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> selectyesno ( 'MAIN_DISABLE_ALL_MAILS' , $conf -> global -> MAIN_DISABLE_ALL_MAILS , 1 );
2009-05-04 20:38:01 +02:00
print '</td></tr>' ;
2009-02-09 01:04:34 +01:00
2017-12-24 17:31:31 +01:00
// Force e-mail recipient
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_FORCE_SENDTO " ) . '</td><td>' ;
2019-11-28 12:36:20 +01:00
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 : '' ) . '" />' ;
2017-12-24 17:31:31 +01:00
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>' ;
2010-08-28 12:55:11 +02:00
2009-05-04 20:38:01 +02:00
// Method
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SENDMODE " ) . '</td><td>' ;
2009-11-01 15:16:30 +01:00
2009-05-04 16:58:40 +02:00
// SuperAdministrator access only
2021-02-26 22:04:03 +01:00
if (( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY )) || ( $user -> admin && ! $user -> entity )) {
2019-01-27 11:55:16 +01:00
print $form -> selectarray ( 'MAIN_MAIL_SENDMODE' , $listofmethods , $conf -> global -> MAIN_MAIL_SENDMODE );
2020-05-21 09:35:30 +02:00
} else {
2009-11-01 15:16:30 +01:00
$text = $listofmethods [ $conf -> global -> MAIN_MAIL_SENDMODE ];
2021-02-26 22:04:03 +01:00
if ( empty ( $text )) {
$text = $langs -> trans ( " Undefined " );
}
2009-05-04 16:58:40 +02:00
$htmltext = $langs -> trans ( " ContactSuperAdminForChange " );
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $text , $htmltext , 1 , 'superadmin' );
2009-05-06 17:25:32 +02:00
print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="' . $conf -> global -> MAIN_MAIL_SENDMODE . '">' ;
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 && $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' ) {
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>' ;
2019-11-28 12:36:20 +01:00
$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
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> multicompany -> enabled ) || ( $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">' ;
2019-11-28 12:36:20 +01:00
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 {
2019-11-28 12:36:20 +01:00
$text = ! empty ( $mainserver ) ? $mainserver : $smtpserver ;
2009-05-04 20:38:01 +02:00
$htmltext = $langs -> trans ( " ContactSuperAdminForChange " );
2019-01-27 11:55:16 +01:00
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
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2021-02-26 22:04:03 +01:00
if ( ! $conf -> use_javascript_ajax && $linuxlike && $conf -> global -> MAIN_MAIL_SENDMODE == '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 {
2019-11-28 12:36:20 +01:00
$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
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> multicompany -> enabled ) || ( $user -> admin && ! $user -> entity )) {
2019-11-28 12:36:20 +01:00
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 {
2019-11-28 12:36:20 +01:00
$text = ( ! empty ( $mainport ) ? $mainport : $smtpport );
2009-05-04 20:38:01 +02:00
$htmltext = $langs -> trans ( " ContactSuperAdminForChange " );
2019-01-27 11:55:16 +01:00
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>' ;
// ID
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' )))) {
2019-11-28 12:36:20 +01:00
$mainstmpid = ( ! empty ( $conf -> global -> MAIN_MAIL_SMTPS_ID ) ? $conf -> global -> MAIN_MAIL_SMTPS_ID : '' );
2018-08-07 10:44:26 +02:00
print '<tr class="drag drop oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_ID " ) . '</td><td>' ;
2009-05-04 20:38:01 +02:00
// SuperAdministrator access only
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> multicompany -> enabled ) || ( $user -> admin && ! $user -> entity )) {
2019-11-28 12:36:20 +01:00
print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="' . $mainstmpid . '">' ;
2020-05-21 09:35:30 +02:00
} else {
2009-05-04 20:38:01 +02:00
$htmltext = $langs -> trans ( " ContactSuperAdminForChange " );
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $conf -> global -> MAIN_MAIL_SMTPS_ID , $htmltext , 1 , 'superadmin' );
2012-07-10 11:45:38 +02:00
print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="' . $mainstmpid . '">' ;
2009-05-04 20:38:01 +02:00
}
print '</td></tr>' ;
2009-05-04 16:58:40 +02:00
}
2009-05-04 20:38:01 +02:00
// PW
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' )))) {
2019-11-28 12:36:20 +01:00
$mainsmtppw = ( ! empty ( $conf -> global -> MAIN_MAIL_SMTPS_PW ) ? $conf -> global -> MAIN_MAIL_SMTPS_PW : '' );
2019-11-25 21:02:26 +01:00
print '<tr class="drag drop oddeven"><td>' ;
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
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> multicompany -> enabled ) || ( $user -> admin && ! $user -> entity )) {
2019-11-28 12:36:20 +01:00
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 " );
2019-01-27 11:55:16 +01:00
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>' ;
}
2020-10-31 14:32:18 +01:00
// TLS
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_TLS " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' )))) {
if ( function_exists ( 'openssl_open' )) {
2019-11-28 12:36:20 +01:00
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 " ) . ')' ;
}
2009-10-28 21:35:59 +01:00
print '</td></tr>' ;
2016-03-16 02:09:55 +01:00
// STARTTLS
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_STARTTLS " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' )))) {
if ( function_exists ( 'openssl_open' )) {
2019-11-28 12:36:20 +01:00
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 " ) . ')' ;
}
2016-03-16 02:09:55 +01:00
print '</td></tr>' ;
2020-09-08 14:48:50 +02:00
// SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' )))) {
if ( function_exists ( 'openssl_open' )) {
2020-09-08 14:48:50 +02:00
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 " ) . ')' ;
}
2020-09-08 14:48:50 +02:00
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>' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'swiftmailer' )))) {
if ( function_exists ( 'openssl_open' )) {
2019-11-28 12:36:20 +01:00
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>' ;
2017-06-11 11:40:01 +02:00
2020-10-31 14:32:18 +01:00
// 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
2020-10-31 14:32:18 +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
2020-10-31 14:32:18 +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>' ;
2017-06-11 11:40:01 +02:00
2009-05-04 20:38:01 +02:00
// From
2020-10-14 12:21:31 +02:00
print '<tr class="oddeven"><td class="fieldrequired">' . $langs -> trans ( " MAIN_MAIL_EMAIL_FROM " , ini_get ( 'sendmail_from' ) ? ini_get ( 'sendmail_from' ) : $langs -> transnoentities ( " Undefined " )) . '</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 : '' );
2010-08-28 12:55:11 +02:00
print '"></td></tr>' ;
2011-07-10 22:03:38 +02:00
2017-10-13 13:28:26 +02:00
// Default from type
2017-10-11 19:41:19 +02:00
$liste = array ();
$liste [ 'user' ] = $langs -> trans ( 'UserEmail' );
2019-11-28 12:36:20 +01:00
$liste [ 'company' ] = $langs -> trans ( 'CompanyEmail' ) . ' (' . ( empty ( $conf -> global -> MAIN_INFO_SOCIETE_MAIL ) ? $langs -> trans ( " NotDefined " ) : $conf -> global -> MAIN_INFO_SOCIETE_MAIL ) . ')' ;
2016-10-15 03:45:23 +02:00
2018-05-03 21:27:52 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) . '</td><td>' ;
2017-10-13 13:28:26 +02:00
print $form -> selectarray ( 'MAIN_MAIL_DEFAULT_FROMTYPE' , $liste , $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE , 0 );
print '</td></tr>' ;
2016-10-15 03:45:23 +02:00
2011-07-09 08:10:04 +02:00
// From
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_ERRORS_TO " ) . '</td>' ;
2019-11-28 12:36:20 +01:00
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 : '' );
2011-07-09 08:10:04 +02:00
print '"></td></tr>' ;
2009-05-04 20:38:01 +02:00
2010-08-28 12:55:11 +02:00
// Autocopy to
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_AUTOCOPY_TO " ) . '</td>' ;
2019-11-28 12:36:20 +01:00
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 : '' );
2010-08-28 12:55:11 +02:00
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>' ;
print $form -> selectyesno ( 'MAIN_MAIL_ENABLED_USER_DEST_SELECT' , $conf -> global -> MAIN_MAIL_ENABLED_USER_DEST_SELECT , 1 );
print '</td></tr>' ;
2017-10-13 13:28:26 +02:00
print '</table>' ;
2016-10-13 16:44:17 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-06-11 11:40:01 +02:00
2017-10-13 13:28:26 +02:00
print '<br><div class="center">' ;
2020-11-19 20:23:38 +01:00
print '<input class="button button-save" type="submit" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
2017-10-13 13:28:26 +02:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input class="button button-cancel" type="submit" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2017-10-13 13:28:26 +02:00
print '</div>' ;
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 );
2017-06-11 11:40:01 +02:00
2019-05-21 21:52:04 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " EMailsDesc " ) . " </span><br> \n " ;
2017-10-13 13:28:26 +02:00
print " <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">' ;
2017-08-24 02:02:00 +02:00
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
2021-04-12 16:03:56 +02:00
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
2020-10-27 11:40:30 +01: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 " ));
}
2020-10-27 11:40:30 +01:00
}
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
2020-10-27 11:40:30 +01: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
2020-10-27 11:40:30 +01:00
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
2020-10-27 11:40:30 +01:00
// Method
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SENDMODE " ) . '</td><td>' ;
$text = $listofmethods [ $conf -> global -> MAIN_MAIL_SENDMODE ];
2021-02-26 22:04:03 +01:00
if ( empty ( $text )) {
$text = $langs -> trans ( " Undefined " ) . img_warning ();
}
2020-10-27 11:40:30 +01:00
print $text ;
2009-05-04 20:38:01 +02:00
2020-10-27 11:40:30 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' && empty ( $conf -> global -> MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP )) {
print $form -> textwithpicto ( '' , $langs -> trans ( " WarningPHPMail " ) . '<br>' . $langs -> trans ( " WarningPHPMailA " ) . '<br>' . $langs -> trans ( " WarningPHPMailB " ) . '<br>' . $langs -> trans ( " WarningPHPMailC " ) . '<br><br>' . $langs -> trans ( " WarningPHPMailD " ), 1 , 'warning' );
}
2009-05-04 20:38:01 +02:00
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2009-05-04 20:38:01 +02:00
2020-10-27 11:40:30 +01:00
// Host server
2021-02-26 22:04:03 +01:00
if ( $linuxlike && ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' )) {
2020-10-27 11:40:30 +01:00
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
2020-10-27 11:40:30 +01:00
// Port
2021-02-26 22:04:03 +01:00
if ( $linuxlike && ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' )) {
2020-10-27 11:40:30 +01:00
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
2020-10-27 11:40:30 +01:00
// SMTPS ID
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' ))) {
2020-10-27 11:40:30 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_ID " ) . '</td><td>' . $conf -> global -> MAIN_MAIL_SMTPS_ID . '</td></tr>' ;
}
2009-10-28 21:35:59 +01:00
2020-10-27 11:40:30 +01:00
// SMTPS PW
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' ))) {
2020-10-27 11:40:30 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_PW " ) . '</td><td>' . preg_replace ( '/./' , '*' , $conf -> global -> MAIN_MAIL_SMTPS_PW ) . '</td></tr>' ;
}
2016-03-16 02:09:55 +01:00
2020-10-27 11:40:30 +01:00
// TLS
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_TLS " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
2020-10-27 11:40:30 +01:00
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>' ;
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2016-03-16 02:09:55 +01:00
2020-10-27 11:40:30 +01:00
// STARTTLS
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_STARTTLS " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
2020-10-27 11:40:30 +01:00
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>' ;
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2018-01-25 22:03:51 +01:00
2020-10-27 11:40:30 +01:00
// SMTP_ALLOW_SELF_SIGNED
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'smtps' , 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
2020-10-27 11:40:30 +01:00
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' ) {
2020-10-27 11:40:30 +01:00
// DKIM
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_DKIM_ENABLED " ) . '</td><td>' ;
2021-02-26 22:04:03 +01:00
if ( isset ( $conf -> global -> MAIN_MAIL_SENDMODE ) && in_array ( $conf -> global -> MAIN_MAIL_SENDMODE , array ( 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
2020-10-27 11:40:30 +01:00
print yn ( $conf -> global -> 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 " ) . ')' ;
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2020-10-31 14:32:18 +01:00
// 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' );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2020-10-27 11:40:30 +01:00
2020-10-31 14:32:18 +01:00
// 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' );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2020-10-27 11:40:30 +01:00
2020-10-31 14:32:18 +01:00
// 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' );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2020-10-27 11:40:30 +01:00
}
2018-01-25 22:03:51 +01:00
2020-10-27 11:40:30 +01:00
print '</table>' ;
2021-01-26 11:19:13 +01:00
print '</div>' ;
2018-01-25 22:03:51 +01:00
2020-10-27 11:40:30 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' && empty ( $conf -> global -> MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP )) {
print info_admin ( $langs -> trans ( " WarningPHPMail " ) . '<br>' . $langs -> trans ( " WarningPHPMailA " ) . '<br>' . $langs -> trans ( " WarningPHPMailB " ) . '<br>' . $langs -> trans ( " WarningPHPMailC " ) . '<br><br>' . $langs -> trans ( " WarningPHPMailD " ), 0 , 0 , 'warning' );
}
2020-09-12 15:39:14 +02:00
2020-10-27 11:40:30 +01: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
2020-10-27 11:40:30 +01:00
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
2020-10-27 11:40:30 +01:00
// From
2021-01-26 13:22:20 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_FROM " , ini_get ( 'sendmail_from' ) ? ini_get ( 'sendmail_from' ) : $langs -> transnoentities ( " Undefined " )) . '</td>' ;
2020-10-27 11:40:30 +01:00
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 " ));
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2010-08-28 12:55:11 +02:00
2020-10-27 11:40:30 +01:00
// 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 ) . ')' ;
2020-10-27 11:40:30 +01:00
$resql = $db -> query ( $sql );
2021-02-26 22:04:03 +01:00
if ( $resql ) {
2020-10-27 11:40:30 +01:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2021-02-26 22:04:03 +01:00
while ( $i < $num ) {
2020-10-27 11:40:30 +01:00
$obj = $db -> fetch_object ( $resql );
2021-02-26 22:04:03 +01:00
if ( $obj ) {
2020-10-27 11:40:30 +01:00
$liste [ 'senderprofile_' . $obj -> rowid ] = $obj -> label . ' <' . $obj -> email . '>' ;
}
$i ++ ;
}
2021-02-26 22:04:03 +01:00
} else {
dol_print_error ( $db );
}
2011-07-10 22:03:38 +02:00
2020-10-27 11:40:30 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) . '</td>' ;
print '<td>' ;
2021-04-14 15:26:18 +02:00
if ( ! empty ( $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE ) && $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE === 'robot' ) {
2021-04-12 16:03:56 +02:00
print $langs -> trans ( 'RobotEmail' );
2021-04-14 15:26:18 +02:00
} elseif ( ! empty ( $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE ) && $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE === 'user' ) {
2021-04-12 16:03:56 +02:00
print $langs -> trans ( 'UserEmail' );
2021-04-14 15:26:18 +02:00
} elseif ( ! empty ( $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE ) && $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE === 'company' ) {
2021-04-12 16:03:56 +02:00
print $langs -> trans ( 'CompanyEmail' ) . ' ' . dol_escape_htmltag ( '<' . $mysoc -> email . '>' );
} else {
$id = preg_replace ( '/senderprofile_/' , '' , ! empty ( $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE ) ? $conf -> global -> 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 . '>' );
2017-10-11 19:41:19 +02:00
}
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2017-06-11 11:40:01 +02:00
2020-10-27 11:40:30 +01:00
// Errors To
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_ERRORS_TO " ) . '</td>' ;
2021-04-12 16:03:56 +02:00
print '<td>' . ( ! empty ( $conf -> global -> MAIN_MAIL_ERRORS_TO ) ? $conf -> global -> 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 " ));
}
2020-10-27 11:40:30 +01:00
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 )) {
2020-10-27 11:40:30 +01:00
print $conf -> global -> MAIN_MAIL_AUTOCOPY_TO ;
2021-02-26 22:04:03 +01:00
if ( ! isValidEmail ( $conf -> global -> MAIN_MAIL_AUTOCOPY_TO )) {
print img_warning ( $langs -> trans ( " ErrorBadEMail " ));
}
2020-10-27 11:40:30 +01:00
} else {
print ' ' ;
2017-10-13 13:28:26 +02:00
}
2020-10-27 11:40:30 +01:00
print '</td></tr>' ;
2016-10-15 03:45:23 +02:00
2020-10-27 11:40:30 +01:00
//Add user to select destinaries list
2021-04-12 16:03:56 +02:00
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>' ;
2010-08-28 12:55:11 +02:00
2020-10-27 11:40:30 +01:00
print '</table>' ;
2021-01-26 11:19:13 +01:00
print '</div>' ;
2012-07-10 11:45:38 +02:00
}
2007-06-16 18:59:52 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-06-11 11:40:01 +02:00
2018-02-04 10:55:09 +01:00
// Actions button
2009-05-04 20:38:01 +02:00
print '<div class="tabsAction">' ;
2009-05-18 03:46:30 +02:00
2009-05-10 04:44:53 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=edit">' . $langs -> trans ( " Modify " ) . '</a>' ;
2009-05-18 03:46:30 +02:00
2020-10-27 11:40:30 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_ALL_MAILS )) {
2021-02-26 22:04:03 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE != 'mail' || ! $linuxlike ) {
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>' ;
2020-10-27 11:40:30 +01:00
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " FeatureNotAvailableOnLinux " ) . '">' . $langs -> trans ( " DoTestServerAvailability " ) . '</a>' ;
2008-09-10 12:20:29 +02:00
}
2009-05-10 04:44:14 +02:00
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>' ;
2009-05-18 03:46:30 +02:00
2021-02-26 22:04:03 +01:00
if ( ! empty ( $conf -> fckeditor -> enabled )) {
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>' ;
2020-10-27 11:40:30 +01:00
}
2008-07-17 01:37:34 +02:00
}
2009-05-18 03:46:30 +02:00
2009-05-04 20:38:01 +02:00
print '</div>' ;
2009-02-09 01:04:34 +01:00
2021-02-26 22:04:03 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE == '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 = '' ;
2021-02-26 22:04:03 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE == '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
2021-02-26 22:04:03 +01:00
if ( $conf -> global -> MAIN_MAIL_SENDMODE == 'mail' ) {
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'
2020-09-27 19:23:52 +02:00
$text .= ( $text ? '<br><br>' : '' ) . $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 )) {
2020-09-27 19:23:52 +02:00
// List of IP show as record to add in SPF if we use the mail method
$text .= ( $text ? '<br><br>' : '' ) . $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
2020-01-29 13:10:16 +01:00
$text .= ( $text ? '<br><br>' : '' ) . $langs -> trans ( " WarningPHPMail2 " , $conf -> global -> MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS );
}
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'
2020-01-29 13:10:16 +01:00
$text .= ( $text ? '<br><br>' : '' ) . $langs -> trans ( " WarningPHPMailSPF " , $conf -> global -> MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD );
}
2018-02-16 23:49:08 +01:00
}
2020-01-29 13:10:16 +01:00
2021-02-26 22:04:03 +01:00
if ( $text ) {
print info_admin ( $text );
}
2016-12-23 19:54:06 +01:00
}
2017-06-11 11:40:01 +02:00
2009-11-01 15:16:30 +01:00
// 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>' ;
2015-09-24 18:27:13 +02:00
print load_fiche_titre ( $langs -> trans ( " DoTestServerAvailability " ));
2009-05-04 20:38:01 +02:00
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
2020-04-05 00:29:34 +02:00
$mail = new CMailFile ( '' , '' , '' , '' , array (), array (), array (), '' , '' , 0 , '' , '' , '' , '' , $trackid , $sendcontext );
2019-11-28 12:36:20 +01:00
$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 {
2019-01-27 11:55:16 +01:00
$errormsg = $langs -> trans ( " ServerNotAvailableOnIPOrPort " , $server , $port );
2014-07-20 01:09:43 +02:00
if ( $mail -> error ) {
$errormsg .= ' - ' . $mail -> error ;
}
2015-10-28 19:28:18 +01:00
setEventMessages ( $errormsg , null , 'errors' );
2021-01-28 19:45:52 +01:00
print $errormsg ;
2009-05-04 20:38:01 +02:00
}
print '<br>' ;
2008-04-17 01:11:45 +02:00
}
2012-11-19 17:42:37 +01:00
// Show email send test form
2021-02-26 22:04:03 +01:00
if ( $action == 'test' || $action == 'testhtml' ) {
2017-10-13 13:28:26 +02:00
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>' ;
2019-11-28 12:36:20 +01:00
print load_fiche_titre ( $action == 'testhtml' ? $langs -> trans ( " DoTestSendHTML " ) : $langs -> trans ( " DoTestSend " ));
2009-05-04 20:38:01 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( '' );
2017-07-14 02:07:01 +02:00
2009-05-04 20:38:01 +02:00
// Cree l'objet formulaire mail
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
2009-05-04 20:38:01 +02:00
$formmail = new FormMail ( $db );
2019-11-28 12:36:20 +01:00
$formmail -> trackid = (( $action == 'testhtml' ) ? " testhtml " : " test " );
2020-11-30 14:47:07 +01:00
$formmail -> fromname = ( GETPOSTISSET ( 'fromname' ) ? $_POST [ 'fromname' ] : $conf -> global -> MAIN_MAIL_EMAIL_FROM );
$formmail -> frommail = ( GETPOSTISSET ( 'frommail' ) ? $_POST [ 'frommail' ] : $conf -> global -> MAIN_MAIL_EMAIL_FROM );
2019-11-28 12:36:20 +01:00
$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 ;
2020-11-30 14:47:07 +01:00
$formmail -> withto = ( ! empty ( $_POST [ 'sendto' ]) ? GETPOST ( 'sendto' , 'restricthtml' ) : ( $user -> email ? $user -> email : 1 ));
$formmail -> withtocc = ( ! empty ( $_POST [ 'sendtocc' ]) ? GETPOST ( 'sendtocc' , 'restricthtml' ) : 1 ); // ! empty to keep field if empty
$formmail -> withtoccc = ( ! empty ( $_POST [ 'sendtoccc' ]) ? GETPOST ( 'sendtoccc' , 'restricthtml' ) : 1 ); // ! empty to keep field if empty
$formmail -> withtopic = ( GETPOSTISSET ( 'subject' ) ? GETPOST ( 'subject' ) : $langs -> trans ( " Test " ));
2019-11-28 12:36:20 +01:00
$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 " )));
2019-11-28 12:36:20 +01:00
$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
2019-11-28 12:36:20 +01:00
$formmail -> substit = $substitutionarrayfortest ;
2009-05-04 20:38:01 +02:00
// Tableau des parametres complementaires du post
2019-11-28 12:36:20 +01:00
$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
2019-01-27 11:55:16 +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 ();
2020-01-29 19:26:04 +01:00
// References
print '<span class="opacitymedium">' . $langs -> trans ( " EMailsWillHaveMessageID " ) . ': ' ;
print dol_escape_htmltag ( '<timestamp.*@' . dol_getprefix ( 'email' ) . '>' );
print '</span>' ;
2007-06-16 18:59:52 +02:00
}
2007-06-08 01:29:53 +02:00
}
2018-07-28 18:03:14 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-01-02 17:36:14 +01:00
$db -> close ();