2007-06-08 01:29:53 +02:00
< ? php
2023-01-26 10:46:59 +01:00
/* Copyright ( C ) 2007 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2009 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2016 Jonathan TISSEAU < jonathan . tisseau @ 86 dev . fr >
* Copyright ( C ) 2023 Anthony Berton < anthony . berton @ bb2a . 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
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
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
2022-10-23 17:14:23 +02:00
$trackid = GETPOST ( 'trackid' );
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 ;
2022-10-23 17:14:23 +02:00
// 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' )) {
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 (
2022-03-17 12:39:39 +01:00
'__USER_LOGIN__' => $user -> login ,
'__USER_EMAIL__' => $user -> email ,
2023-10-24 17:00:13 +02:00
'__USER_SIGNATURE__' => (( $user -> signature && ! getDolGlobalString ( 'MAIN_MAIL_DO_NOT_USE_SIGN' )) ? $usersignature : '' ), // Done into actions_sendmails
'__SENDEREMAIL_SIGNATURE__' => (( $user -> signature && ! getDolGlobalString ( 'MAIN_MAIL_DO_NOT_USE_SIGN' )) ? $usersignature : '' ), // Done into actions_sendmails
2023-11-28 20:56:20 +01:00
'__ID__' => 'RecipientID' ,
2022-03-17 12:39:39 +01:00
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
2020-05-28 11:41:48 +02:00
'__LASTNAME__' => 'RecipientLastname' ,
'__FIRSTNAME__' => 'RecipientFirstname' ,
'__ADDRESS__' => 'RecipientAddress' ,
'__ZIP__' => 'RecipientZip' ,
'__TOWN_' => 'RecipientTown' ,
2023-11-28 20:56:20 +01:00
'__COUNTRY__' => 'RecipientCountry' ,
'__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 ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . " -undefinedtag " , 'md5' ) . '" width="1" height="1" style="width:1px;height:1px" border="0" />' ,
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 );
2023-01-25 23:56:57 +01:00
dolibarr_set_const ( $db , 'MAIN_MAIL_NO_WITH_TO_SELECTED' , GETPOST ( 'MAIN_MAIL_NO_WITH_TO_SELECTED' , 'int' ), 'chaine' , 0 , '' , $conf -> entity );
2020-10-14 12:21:31 +02:00
// 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 );
}
2022-08-03 20:01:13 +02:00
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 11:31:32 +02:00
}
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
}
2020-10-14 12:21:31 +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 );
2023-01-25 23:56:57 +01:00
2020-10-14 12:21:31 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?mainmenu=home&leftmenu=setup " );
exit ;
}
2007-06-08 01:29:53 +02:00
}
2022-10-17 01:23:56 +02:00
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' );
}
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' ;
2022-10-23 17:14:23 +02:00
$trackid = ( $action == 'send' ? GETPOST ( 'trackid' , 'aZ09' ) : $action );
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
/*
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
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_MAIL_SENDMODE' )) {
2021-02-26 22:04:03 +01:00
$conf -> global -> MAIN_MAIL_SENDMODE = 'mail' ;
}
2023-10-24 17:00:13 +02:00
$port = getDolGlobalString ( '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 ;
}
2023-10-24 17:00:13 +02:00
$server = getDolGlobalString ( '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
2022-08-01 11:31:32 +02:00
// 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 );
2022-08-03 21:14:38 +02:00
$provider = ucfirst ( strtolower ( $provider ));
2022-08-01 11:31:32 +02:00
$oauthservices [ $key ] = $name . " ( " . $provider . " ) " ;
}
}
2007-06-08 01:29:53 +02:00
2021-02-26 22:04:03 +01:00
if ( $action == 'edit' ) {
if ( $conf -> use_javascript_ajax ) {
2021-11-29 15:09:18 +01:00
print " \n " . '<script type="text/javascript">' ;
2011-09-14 23:50:18 +02:00
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 ();
2022-08-03 20:01:13 +02:00
jQuery ( " .smtp_auth_method " ) . 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 ();
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_TLS ').' );
2015-05-12 14:47:33 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . removeAttr ( " disabled " );
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_STARTTLS ').' );
2016-03-16 02:09:55 +01:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . removeAttr ( " disabled " );
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED ').' );
2020-09-08 14:48:50 +02:00
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 ();
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 ();
2022-08-03 20:01:13 +02:00
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 ();
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_TLS ').' );
2016-04-16 18:15:03 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_TLS " ) . removeAttr ( " disabled " );
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_STARTTLS ').' );
2016-04-16 18:15:03 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_STARTTLS " ) . removeAttr ( " disabled " );
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED ').' );
2020-09-08 14:48:50 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . removeAttr ( " disabled " );
2023-10-11 19:44:06 +02:00
jQuery ( " #MAIN_MAIL_EMAIL_DKIM_ENABLED " ) . val ( ' . getDolGlobalString(' MAIN_MAIL_EMAIL_DKIM_ENABLED ').' );
2018-01-25 22:03:51 +01:00
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
}
2011-03-25 23:07:14 +01:00
}
2022-08-03 20:01:13 +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 " )) {
2022-08-01 11:31:32 +02:00
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 ();
2022-08-03 20:01:13 +02:00
} else if ( jQuery ( " #MAIN_MAIL_SENDMODE " ) . val () == \ ' mail\ ' ){
jQuery ( " .smtp_oauth_service " ) . hide ();
jQuery ( " .smtp_pw " ) . hide ();
2022-08-01 11:31:32 +02:00
} else {
jQuery ( " .smtp_oauth_service " ) . hide ();
jQuery ( " .smtp_pw " ) . show ();
}
}
2011-03-25 23:07:14 +01:00
initfields ();
2022-08-03 20:01:13 +02:00
change_smtp_auth_method ();
2011-03-25 23:07:14 +01:00
jQuery ( " #MAIN_MAIL_SENDMODE " ) . change ( function () {
initfields ();
2022-08-03 20:01:13 +02:00
change_smtp_auth_method ();
2011-03-25 23:07:14 +01:00
});
2022-08-03 20:01:13 +02:00
jQuery ( " #radio_pw, #radio_oauth " ) . change ( function () {
change_smtp_auth_method ();
2022-08-01 11:31:32 +02:00
});
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 " ;
2021-10-18 16:22:19 +02:00
print " <br><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
2018-03-21 11:48:30 +01:00
2020-09-12 15:39:14 +02:00
print '<table class="noborder centpercent">' ;
2023-11-28 20:56:20 +01:00
print '<tr class="liste_titre"><td class="titlefieldmiddle">' . $langs -> trans ( " Parameters " ) . '</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
2023-10-13 15:00:51 +02:00
if ( ! isModEnabled ( 'multicompany' ) || ( $user -> admin && ! $user -> entity )) {
2022-10-17 01:23:56 +02:00
print $form -> selectarray ( 'MAIN_MAIL_SENDMODE' , $listofmethods , getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ));
2020-05-21 09:35:30 +02:00
} else {
2023-10-11 19:44:06 +02:00
$text = $listofmethods [ getDolGlobalString ( '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' );
2022-10-17 01:23:56 +02:00
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
2023-11-27 20:20:30 +01:00
print '<tr class="oddeven hideonmodemail">' ;
2022-10-17 01:23:56 +02:00
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>' ;
2023-10-24 17:00:13 +02:00
$mainserver = ( getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' ) ? $conf -> global -> MAIN_MAIL_SMTP_SERVER : '' );
2023-12-04 11:41:14 +01:00
$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">' ;
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
2023-11-27 20:20:30 +01:00
print '<tr class="oddeven hideonmodemail"><td>' ;
2022-10-17 01:23:56 +02:00
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 {
2023-10-24 17:00:13 +02:00
$mainport = ( getDolGlobalString ( 'MAIN_MAIL_SMTP_PORT' ) ? $conf -> global -> MAIN_MAIL_SMTP_PORT : '' );
2023-12-04 11:41:14 +01:00
$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 )) {
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>' ;
2022-11-18 12:03:50 +01:00
// Auth mode
2022-10-17 01:23:56 +02:00
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 ' ' ;
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 16:58:40 +02:00
}
2009-05-04 20:38:01 +02:00
2022-11-18 12:03:50 +01:00
// ID
2022-10-17 01:23:56 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' )))) {
2023-10-24 17:00:13 +02:00
$mainstmpid = ( getDolGlobalString ( 'MAIN_MAIL_SMTPS_ID' ) ? $conf -> global -> MAIN_MAIL_SMTPS_ID : '' );
2022-11-18 12:03:50 +01:00
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 . '">' ;
2022-08-03 20:01:13 +02:00
} 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 . '">' ;
2022-08-03 20:01:13 +02:00
}
print '</td></tr>' ;
}
2022-11-18 12:03:50 +01:00
2009-05-04 20:38:01 +02:00
// PW
2022-10-17 01:23:56 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' )))) {
2023-10-24 17:00:13 +02:00
$mainsmtppw = ( getDolGlobalString ( 'MAIN_MAIL_SMTPS_PW' ) ? $conf -> global -> MAIN_MAIL_SMTPS_PW : '' );
2022-08-01 11:31:32 +02:00
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 )) {
2023-06-23 02:32:54 +02:00
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . htmlspecialchars ( $mainsmtppw , ENT_COMPAT , 'UTF-8' ) . '" 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' );
2023-06-23 02:32:54 +02:00
print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="' . htmlspecialchars ( $mainsmtppw , ENT_COMPAT , 'UTF-8' ) . '">' ;
2009-05-04 20:38:01 +02:00
}
print '</td></tr>' ;
}
2022-08-01 11:31:32 +02:00
// OAUTH service provider
2022-10-17 01:23:56 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) || ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' )))) {
2022-08-03 20:01:13 +02:00
print '<tr class="oddeven smtp_oauth_service"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_OAUTH_SERVICE " ) . '</td><td>' ;
2022-08-01 11:31:32 +02:00
// SuperAdministrator access only
2023-10-13 15:00:51 +02:00
if ( ! isModEnabled ( 'multicompany' ) || ( $user -> admin && ! $user -> entity )) {
2022-08-01 11:31:32 +02:00
print $form -> selectarray ( 'MAIN_MAIL_SMTPS_OAUTH_SERVICE' , $oauthservices , $conf -> global -> MAIN_MAIL_SMTPS_OAUTH_SERVICE );
} else {
2023-10-11 19:44:06 +02:00
$text = $oauthservices [ getDolGlobalString ( 'MAIN_MAIL_SMTPS_OAUTH_SERVICE' )];
2022-08-01 11:31:32 +02:00
if ( empty ( $text )) {
$text = $langs -> trans ( " Undefined " );
}
$htmltext = $langs -> trans ( " ContactSuperAdminForChange " );
print $form -> textwithpicto ( $text , $htmltext , 1 , 'superadmin' );
2023-10-11 19:44:06 +02:00
print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="' . getDolGlobalString ( 'MAIN_MAIL_SMTPS_OAUTH_SERVICE' ) . '">' ;
2022-08-01 11:31:32 +02:00
}
print '</td></tr>' ;
}
2023-11-27 20:20:30 +01:00
2020-10-31 14:32:18 +01:00
// TLS
2023-11-27 20:20:30 +01:00
print '<tr class="oddeven hideonmodemail"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_TLS " ) . '</td><td>' ;
2022-10-17 01:23:56 +02:00
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' )) {
2023-10-24 17:00:13 +02:00
print $form -> selectyesno ( 'MAIN_MAIL_EMAIL_TLS' , ( getDolGlobalString ( '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
2023-11-27 20:20:30 +01:00
print '<tr class="oddeven hideonmodemail"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_STARTTLS " ) . '</td><td>' ;
2022-10-17 01:23:56 +02:00
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' )) {
2023-10-24 17:00:13 +02:00
print $form -> selectyesno ( 'MAIN_MAIL_EMAIL_STARTTLS' , ( getDolGlobalString ( '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
2023-11-27 20:20:30 +01:00
print '<tr class="oddeven hideonmodemail"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED " ) . '</td><td>' ;
2022-10-17 01:23:56 +02:00
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' )) {
2023-10-24 17:00:13 +02:00
print $form -> selectyesno ( 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED' , ( getDolGlobalString ( 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED' ) ? $conf -> global -> MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED : 0 ), 1 );
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>' ;
2022-10-17 01:23:56 +02:00
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' )) {
2023-10-24 17:00:13 +02:00
print $form -> selectyesno ( 'MAIN_MAIL_EMAIL_DKIM_ENABLED' , ( getDolGlobalString ( '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>' ;
2023-10-24 17:00:13 +02:00
print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="' . ( getDolGlobalString ( 'MAIN_MAIL_EMAIL_DKIM_DOMAIN' ) ? $conf -> global -> MAIN_MAIL_EMAIL_DKIM_DOMAIN : '' );
2020-10-31 14:32:18 +01:00
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>' ;
2023-10-24 17:00:13 +02:00
print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="' . ( getDolGlobalString ( 'MAIN_MAIL_EMAIL_DKIM_SELECTOR' ) ? $conf -> global -> MAIN_MAIL_EMAIL_DKIM_SELECTOR : '' );
2020-10-31 14:32:18 +01:00
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>' ;
2023-10-24 17:00:13 +02:00
print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">' . ( getDolGlobalString ( 'MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY' ) ? $conf -> global -> MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY : '' ) . '</textarea>' ;
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2018-01-25 22:03:51 +01:00
2020-09-12 15:39:14 +02:00
print '</table>' ;
2023-11-28 20:56:20 +01:00
2020-09-12 15:39:14 +02:00
print '<br>' ;
2023-11-28 20:56:20 +01:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><td class="titlefieldmiddle">' . $langs -> trans ( " ParametersForTestEnvironment " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td></tr>' ;
// Disable
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_DISABLE_ALL_MAILS " ) . '</td><td>' ;
print $form -> selectyesno ( 'MAIN_DISABLE_ALL_MAILS' , getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' ), 1 );
print '</td></tr>' ;
// 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="' . ( getDolGlobalString ( 'MAIN_MAIL_FORCE_SENDTO' ) ? $conf -> global -> MAIN_MAIL_FORCE_SENDTO : '' ) . '" />' ;
print '</td></tr>' ;
print '</table>' ;
print '<br>' ;
2020-09-12 15:39:14 +02:00
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
2023-11-27 20:20:30 +01:00
$help = $form -> textwithpicto ( '' , $langs -> trans ( " EMailHelpMsgSPFDKIM " ));
print '<tr class="oddeven"><td class="fieldrequired">' ;
2023-12-04 11:41:14 +01:00
print $langs -> trans ( " MAIN_MAIL_EMAIL_FROM " , ini_get ( 'sendmail_from' ) ? ini_get ( 'sendmail_from' ) : $langs -> transnoentities ( " Undefined " ));
2023-11-27 20:20:30 +01:00
print ' ' . $help ;
print '</td>' ;
2023-10-24 17:00:13 +02:00
print '<td><input class="flat minwidth200" name="MAIN_MAIL_EMAIL_FROM" value="' . ( getDolGlobalString ( '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' );
2023-10-24 17:00:13 +02:00
$liste [ 'company' ] = $langs -> trans ( 'CompanyEmail' ) . ' (' . ( ! getDolGlobalString ( '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>' ;
2021-05-20 17:40:44 +02:00
print $form -> selectarray ( 'MAIN_MAIL_DEFAULT_FROMTYPE' , $liste , getDolGlobalString ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ), 0 );
2017-10-13 13:28:26 +02:00
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>' ;
2023-10-24 17:00:13 +02:00
print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="' . ( getDolGlobalString ( '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>' ;
2023-10-24 17:00:13 +02:00
print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . ( getDolGlobalString ( '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>' ;
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>' ;
2023-01-25 23:56:57 +01:00
//Disable autoselect to
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_NO_WITH_TO_SELECTED " ) . '</td><td>' ;
print $form -> selectyesno ( 'MAIN_MAIL_NO_WITH_TO_SELECTED' , getDolGlobalString ( 'MAIN_MAIL_NO_WITH_TO_SELECTED' ), 1 );
print '</td></tr>' ;
2020-09-12 15:39:14 +02:00
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
2021-08-20 14:41:30 +02:00
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 );
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 " ;
2021-10-18 16:22:19 +02:00
print " <br><br> \n " ;
2018-06-13 17:03:46 +02:00
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' )) {
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">' ;
2023-11-28 20:56:20 +01:00
print '<tr class="liste_titre"><td class="titlefieldmiddle">' . $langs -> trans ( " Parameters " ) . '</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>' ;
2022-10-17 01:23:56 +02:00
$text = $listofmethods [ getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' )];
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
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' && ! getDolGlobalString ( 'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP' )) {
2022-10-17 01:23:56 +02:00
$textwarning = $langs -> trans ( " WarningPHPMail " ) . '<br>' . $langs -> trans ( " WarningPHPMailA " ) . '<br>' . $langs -> trans ( " WarningPHPMailB " ) . '<br>' . $langs -> trans ( " WarningPHPMailC " ) . '<br><br>' . $langs -> trans ( " WarningPHPMailD " );
2023-11-28 20:56:20 +01:00
print $form -> textwithpicto ( '' , '<span class="small">' . $textwarning . '</span>' , 1 , 'warning' , 'nomargintop' );
2020-10-27 11:40:30 +01:00
}
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
2022-10-17 01:23:56 +02:00
if ( $linuxlike && ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' )) {
2023-11-27 20:20: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>';
2020-10-27 11:40:30 +01:00
} else {
2023-12-04 11:41:14 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTP_SERVER " , ini_get ( 'SMTP' ) ? ini_get ( 'SMTP' ) : $langs -> transnoentities ( " Undefined " )) . '</td><td>' . ( getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' ) ? $conf -> global -> MAIN_MAIL_SMTP_SERVER : '' ) . '</td></tr>' ;
2020-10-27 11:40:30 +01:00
}
2009-05-04 20:38:01 +02:00
2022-08-01 11:31:32 +02:00
2020-10-27 11:40:30 +01:00
// Port
2022-10-17 01:23:56 +02:00
if ( $linuxlike && ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' )) {
2023-11-27 20:20: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>';
2020-10-27 11:40:30 +01:00
} else {
2023-12-04 11:41:14 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTP_PORT " , ini_get ( 'smtp_port' ) ? ini_get ( 'smtp_port' ) : $langs -> transnoentities ( " Undefined " )) . '</td><td>' . ( getDolGlobalString ( 'MAIN_MAIL_SMTP_PORT' ) ? $conf -> global -> MAIN_MAIL_SMTP_PORT : '' ) . '</td></tr>' ;
2020-10-27 11:40:30 +01:00
}
2009-05-04 20:38:01 +02:00
2022-08-03 20:01:13 +02:00
// AUTH method
2022-10-17 01:23:56 +02:00
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' );
2023-12-04 11:41:14 +01:00
$text = ( $authtype === " LOGIN " ) ? $langs -> trans ( " UsePassword " ) : ( $authtype === " XOAUTH2 " ? $langs -> trans ( " UseOauth " ) : '' ) ;
2022-08-03 20:01:13 +02:00
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' ))) {
2023-10-11 19:44:06 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_ID " ) . '</td><td>' . getDolGlobalString ( 'MAIN_MAIL_SMTPS_ID' ) . '</td></tr>' ;
2022-11-18 12:03:50 +01:00
}
2020-10-27 11:40:30 +01:00
// SMTPS PW
2022-10-17 01:23:56 +02:00
if ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' )) && getDolGlobalString ( 'MAIN_MAIL_SMTPS_AUTH_TYPE' ) != " XOAUTH2 " ) {
2023-12-06 13:35:43 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_SMTPS_PW " ) . '</td><td>' . preg_replace ( '/./' , '*' , getDolGlobalString ( 'MAIN_MAIL_SMTPS_PW' )) . '</td></tr>' ;
2020-10-27 11:40:30 +01:00
}
2016-03-16 02:09:55 +01:00
2022-08-01 11:31:32 +02:00
// SMTPS oauth service
2022-10-17 01:23:56 +02:00
if ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' )) && getDolGlobalString ( 'MAIN_MAIL_SMTPS_AUTH_TYPE' ) === " XOAUTH2 " ) {
2023-10-11 19:44:06 +02:00
$text = $oauthservices [ getDolGlobalString ( 'MAIN_MAIL_SMTPS_OAUTH_SERVICE' )];
2022-08-01 11:31:32 +02:00
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>' ;
}
2020-10-27 11:40:30 +01:00
// TLS
2023-11-27 20:20:30 +01:00
if ( $linuxlike && ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' )) {
// Nothing
} else {
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_TLS " ) . '</td><td>' ;
if ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
print yn ( $conf -> global -> MAIN_MAIL_EMAIL_TLS );
} else {
print yn ( 0 ) . ' (' . $langs -> trans ( " YourPHPDoesNotHaveSSLSupport " ) . ')' ;
}
2021-02-26 22:04:03 +01:00
} else {
2023-11-27 20:20:30 +01:00
print '<span class="opacitymedium">' . yn ( 0 ) . ' (' . $langs -> trans ( " NotSupported " ) . ')</span>' ;
2021-02-26 22:04:03 +01:00
}
2023-11-27 20:20:30 +01:00
print '</td></tr>' ;
2021-02-26 22:04:03 +01:00
}
2016-03-16 02:09:55 +01:00
2020-10-27 11:40:30 +01:00
// STARTTLS
2023-11-27 20:20:30 +01:00
if ( $linuxlike && ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' )) {
// Nothing
} else {
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_EMAIL_STARTTLS " ) . '</td><td>' ;
if ( in_array ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ), array ( 'smtps' , 'swiftmailer' ))) {
if ( function_exists ( 'openssl_open' )) {
print yn ( $conf -> global -> MAIN_MAIL_EMAIL_STARTTLS );
} else {
print yn ( 0 ) . ' (' . $langs -> trans ( " YourPHPDoesNotHaveSSLSupport " ) . ')' ;
}
2021-02-26 22:04:03 +01:00
} else {
2023-11-27 20:20:30 +01:00
//print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
2021-02-26 22:04:03 +01:00
}
2023-11-27 20:20:30 +01:00
print '</td></tr>' ;
2021-02-26 22:04:03 +01:00
}
2018-01-25 22:03:51 +01:00
2020-10-27 11:40:30 +01:00
// SMTP_ALLOW_SELF_SIGNED
2023-11-27 20:20:30 +01:00
if ( $linuxlike && ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' )) {
// Nothing
} else {
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' ))) {
if ( function_exists ( 'openssl_open' )) {
print yn ( $conf -> global -> MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED );
} else {
print yn ( 0 ) . ' (' . $langs -> trans ( " YourPHPDoesNotHaveSSLSupport " ) . ')' ;
}
2021-02-26 22:04:03 +01:00
} else {
2023-11-27 20:20:30 +01:00
print '<span class="opacitymedium">' . yn ( 0 ) . ' (' . $langs -> trans ( " NotSupported " ) . ')</span>' ;
2021-02-26 22:04:03 +01:00
}
2023-11-27 20:20:30 +01:00
print '</td></tr>' ;
2021-02-26 22:04:03 +01:00
}
2018-01-25 22:03:51 +01:00
2023-10-08 23:19:49 +02:00
if ( getDolGlobalString ( '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>' ;
2022-10-17 01:23:56 +02:00
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 " ) . ')' ;
}
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
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' && ! getDolGlobalString ( 'MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP' )) {
2022-10-17 01:23:56 +02:00
$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}' );
2023-04-25 22:15:51 +02:00
$linktosetvar1 = '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?action=disablephpmailwarning&token=' . newToken () . '">' ;
2022-10-17 01:23:56 +02:00
$linktosetvar2 = '</a>' ;
$messagetoshow = str_replace ( '{s1}' , $linktosetvar1 , $messagetoshow );
$messagetoshow = str_replace ( '{s2}' , $linktosetvar2 , $messagetoshow );
2023-11-28 20:56:20 +01:00
print info_admin ( $messagetoshow , 0 , 0 , 'warning nomargintop' );
}
print '<br>' ;
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 ( " ParametersForTestEnvironment " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td></tr>' ;
// Disable
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_DISABLE_ALL_MAILS " ) . '</td><td>' . yn ( getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' ));
if ( getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' )) {
print img_warning ( $langs -> trans ( " Disabled " ));
2020-10-27 11:40:30 +01:00
}
2023-11-28 20:56:20 +01:00
print '</td></tr>' ;
if ( ! getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' )) {
// Force e-mail recipient
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_FORCE_SENDTO " ) . '</td><td>' . getDolGlobalString ( 'MAIN_MAIL_FORCE_SENDTO' );
if ( getDolGlobalString ( 'MAIN_MAIL_FORCE_SENDTO' )) {
if ( ! isValidEmail ( getDolGlobalString ( 'MAIN_MAIL_FORCE_SENDTO' ))) {
print img_warning ( $langs -> trans ( " ErrorBadEMail " ));
} else {
print img_warning ( $langs -> trans ( " RecipientEmailsWillBeReplacedWithThisValue " ));
}
}
print '</td></tr>' ;
}
print '</table>' ;
print '</div>' ;
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
2023-11-28 20:56:20 +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 ( " OtherOptions " ) . '</td><td></td></tr>' ;
2020-09-12 15:39:14 +02:00
2020-10-27 11:40:30 +01:00
// From
2023-11-27 20:20:30 +01:00
$help = $form -> textwithpicto ( '' , $langs -> trans ( " EMailHelpMsgSPFDKIM " ));
print '<tr class="oddeven"><td>' ;
2023-12-04 11:41:14 +01:00
print $langs -> trans ( " MAIN_MAIL_EMAIL_FROM " , ini_get ( 'sendmail_from' ) ? ini_get ( 'sendmail_from' ) : $langs -> transnoentities ( " Undefined " ));
2023-11-27 20:20:30 +01:00
print ' ' . $help ;
print '</td>' ;
2023-10-11 19:44:06 +02:00
print '<td>' . getDolGlobalString ( 'MAIN_MAIL_EMAIL_FROM' );
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_MAIL_EMAIL_FROM' )) {
2021-02-26 22:04:03 +01:00
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' );
2023-10-24 17:00:13 +02:00
$liste [ 'company' ] = $langs -> trans ( 'CompanyEmail' ) . ' (' . ( ! getDolGlobalString ( 'MAIN_INFO_SOCIETE_MAIL' ) ? $langs -> trans ( " NotDefined " ) : $conf -> global -> MAIN_INFO_SOCIETE_MAIL ) . ')' ;
2020-10-27 11:40:30 +01:00
$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-23 18:01:11 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) === 'robot' ) {
2021-04-12 16:03:56 +02:00
print $langs -> trans ( 'RobotEmail' );
2021-04-23 18:01:11 +02:00
} elseif ( getDolGlobalString ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) === 'user' ) {
2021-04-12 16:03:56 +02:00
print $langs -> trans ( 'UserEmail' );
2021-04-23 18:01:11 +02:00
} elseif ( getDolGlobalString ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) === 'company' ) {
2021-04-12 16:03:56 +02:00
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' ));
2021-04-12 16:03:56 +02:00
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-23 18:01:11 +02:00
print '<td>' . ( getDolGlobalString ( 'MAIN_MAIL_ERRORS_TO' ));
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_ERRORS_TO' ) && ! isValidEmail ( $conf -> global -> MAIN_MAIL_ERRORS_TO )) {
2021-02-26 22:04:03 +01:00
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>' ;
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_AUTOCOPY_TO' )) {
2023-12-13 15:20:53 +01:00
$listofemail = explode ( ',' , getDolGlobalString ( 'MAIN_MAIL_AUTOCOPY_TO' ));
2022-03-17 12:39:39 +01:00
$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
}
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
2023-10-24 17:00:13 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_ENABLED_USER_DEST_SELECT " ) . '</td><td>' . yn ( getDolGlobalString ( 'MAIN_MAIL_ENABLED_USER_DEST_SELECT' )) . '</td></tr>' ;
2023-01-25 23:56:57 +01:00
//Disable autoselect to
2023-10-24 17:00:13 +02:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAIL_NO_WITH_TO_SELECTED " ) . '</td><td>' . yn ( getDolGlobalString ( 'MAIN_MAIL_NO_WITH_TO_SELECTED' )) . '</td></tr>' ;
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
2021-09-27 12:24:01 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=edit&token=' . newToken () . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
2009-05-18 03:46:30 +02:00
2023-10-24 17:00:13 +02:00
if ( ! getDolGlobalString ( 'MAIN_DISABLE_ALL_MAILS' )) {
2022-10-17 01:23:56 +02:00
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>' ;
2020-10-27 11:40:30 +01:00
}
} else {
2023-04-03 23:00:30 +02:00
//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
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>' ;
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
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' && ! getDolGlobalString ( '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 = '' ;
2022-10-17 01:23:56 +02:00
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
2022-10-17 01:23:56 +02:00
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' , 'mail' ) == 'mail' ) {
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( '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 );
2020-09-27 19:23:52 +02:00
} 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]'.
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( '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
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-09-27 19:23:52 +02:00
}
2020-01-29 13:10:16 +01:00
}
} else {
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( '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
}
2023-10-24 17:00:13 +02:00
if ( getDolGlobalString ( '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 ;
2023-11-27 11:39:32 +01:00
if ( ! empty ( $companyemail ) && function_exists ( 'dns_get_record' ) && ! getDolGlobalString ( 'MAIN_DISABLE_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 );
}
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' );
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
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
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 " );
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 );
2019-11-28 12:36:20 +01:00
$formmail -> fromid = $user -> id ;
$formmail -> fromalsorobot = 1 ;
2023-12-04 11:41:14 +01:00
$formmail -> fromtype = ( GETPOSTISSET ( 'fromtype' ) ? GETPOST ( 'fromtype' , 'aZ09' ) : ( getDolGlobalString ( 'MAIN_MAIL_DEFAULT_FROMTYPE' ) ? $conf -> global -> MAIN_MAIL_DEFAULT_FROMTYPE : 'user' ));
2019-11-28 12:36:20 +01:00
$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 " ));
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
2023-04-03 23:00:30 +02:00
print '<br><br>' ;
2020-01-29 19:26:04 +01:00
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 ();