FIX use correct smtp setup for the check_server_port() test

This commit is contained in:
Laurent Destailleur 2022-08-31 14:02:09 +02:00
parent e0b1ad308b
commit 28c4dd88a2

View File

@ -156,7 +156,7 @@ class CMailFile
* @param string $errors_to Email for errors-to
* @param string $css Css option
* @param string $trackid Tracking string (contains type and id of related element)
* @param string $moreinheader More in header. $moreinheader must contains the "\r\n" (TODO not supported for other MAIL_SEND_MODE different than 'phpmail' and 'smtps' for the moment)
* @param string $moreinheader More in header. $moreinheader must contains the "\r\n" (TODO not supported for other MAIL_SEND_MODE different than 'mail' and 'smtps' for the moment)
* @param string $sendcontext 'standard', 'emailing', ... (used to define which sending mode and parameters to use)
* @param string $replyto Reply-to email (will be set to same value than From by default if not provided)
*/
@ -173,12 +173,11 @@ class CMailFile
$this->sendcontext = $sendcontext;
// Define this->sendmode
// Define this->sendmode ('mail', 'smtps', 'siwftmailer', ...) according to $sendcontext ('standard', 'emailing', 'ticket')
$this->sendmode = '';
if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext);
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
$smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode};
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$this->sendmode = $smtpContextSendMode;
}
@ -329,8 +328,7 @@ class CMailFile
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext);
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
$smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode};
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
}
@ -701,8 +699,7 @@ class CMailFile
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext);
$keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey;
$smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode};
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
@ -1537,15 +1534,26 @@ class CMailFile
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING';
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_EMAILING';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_EMAILING';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_EMAILING';
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_EMAILING';
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext);
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
}
}
// If we use SSL/TLS