diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 53937687b5732..148fcf7626869 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -230,7 +230,6 @@ if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; - if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail'; $port=! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:ini_get('smtp_port'); if (! $port) $port=25; @@ -275,8 +274,21 @@ function initfields() '; if ($linuxlike) { - print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true);'; - print ' jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true);'; + print ' + jQuery("#MAIN_MAIL_SMTP_SERVER").hide(); + jQuery("#MAIN_MAIL_SMTP_PORT").hide(); + jQuery("#smtp_server_mess").show(); + jQuery("#smtp_port_mess").show(); + '; + } + else + { + print ' + jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); + jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); + jQuery("#smtp_server_mess").hide(); + jQuery("#smtp_port_mess").hide(); + '; } print ' } @@ -287,7 +299,11 @@ function initfields() jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr("disabled"); 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(); + } } initfields(); jQuery("#MAIN_MAIL_SENDMODE").change(function() { @@ -336,7 +352,7 @@ function initfields() } print ''; - // Server + // Host server $var=!$var; print ''; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') @@ -357,6 +373,7 @@ function initfields() { print ''; print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { @@ -389,6 +406,7 @@ function initfields() { print ''; print ''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { @@ -509,7 +527,7 @@ function initfields() print $text; print ''; - // Server + // Host server $var=!$var; if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 1aadc47b79ee1..ef6d27b59b1ee 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -39,7 +39,7 @@ class CMailFile var $subject; // Topic: Subject of email var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). - // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain. + // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. var $errors_to; // Errors-To: Email where to send errors. var $addr_to; @@ -408,8 +408,8 @@ function sendfile() $bounce = ''; // By default if (! empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F)) { - // le return-path dans les header ne fonctionne pas avec tous les MTA - // Le passage par -f est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie. + // le "Return-Path" (retour des messages bounced) dans les header ne fonctionne pas avec tous les MTA + // Le forcage de la valeure grace à l'option -f de sendmail est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie. // La variable definie pose des pb avec certains sendmail securisee (option -f refusee car dangereuse) $bounce .= ($bounce?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO,2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from,2) : '') ); } @@ -427,7 +427,15 @@ function sendfile() if (! $res) { - $this->error="Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')."
Check your server logs and your firewalls setup"; + $this->error="Failed to send mail with php mail"; + $linuxlike=1; + if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; + if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; + if (! $linuxlike) + { + $this->error.=" to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'); // This values are value used only for non linuxlike systems + } + $this->error.=".
Check your server logs and your firewalls setup"; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); } else