fixZ: Send IMAP ID command after successful authentication to ensure compatibility with 163 mail servers #25

This commit is contained in:
rustmailer
2025-11-30 17:40:10 +08:00
parent 34ec3a7d5b
commit 3a2b42f5c3
2 changed files with 14 additions and 2 deletions
-1
View File
@@ -16,7 +16,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::modules::error::code::ErrorCode;
use crate::modules::imap::session::SessionStream;
use crate::{modules::error::BichonResult, raise_error};
+14 -1
View File
@@ -28,7 +28,7 @@ use crate::modules::imap::client::Client;
use crate::modules::imap::oauth2::OAuth2;
use crate::modules::imap::session::SessionStream;
use crate::modules::oauth2::token::OAuth2AccessToken;
use crate::{decrypt, raise_error};
use crate::{bichon_version, decrypt, raise_error};
use async_imap::Session;
use tracing::error;
@@ -143,6 +143,19 @@ impl ImapConnectionManager {
.await;
return Err(error);
}
if capabilities.has_str("ID") || capabilities.has_str("id") {
session
.id([
("name", Some("bichon")),
("version", Some(bichon_version!())),
("vendor", Some("rustmailer")),
])
.await
.map_err(|e| {
raise_error!(format!("{:#?}", e), ErrorCode::ImapCommandFailed)
})?;
}
}
Err(error) => {
error!("Failed to fetch IMAP capabilities: {:#?}", error);