mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
fix(smtp): use correct auth mechanisms
This commit is contained in:
committed by
holger krekel
parent
076616bfb9
commit
4a2e1897a6
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -500,7 +500,7 @@ dependencies = [
|
||||
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jetscii 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lettre 0.9.2 (git+https://github.com/deltachat/lettre)",
|
||||
"lettre 0.9.2 (git+https://github.com/deltachat/lettre?branch=feat/multi-auth)",
|
||||
"libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mmime 0.1.2",
|
||||
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1081,7 +1081,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lettre"
|
||||
version = "0.9.2"
|
||||
source = "git+https://github.com/deltachat/lettre#aeec999c27a70870e4b7b149e45f24188c1ff351"
|
||||
source = "git+https://github.com/deltachat/lettre?branch=feat/multi-auth#119ef8e5a003e0afb3abcbe706951cf827bdac2c"
|
||||
dependencies = [
|
||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2945,7 +2945,7 @@ dependencies = [
|
||||
"checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum lettre 0.9.2 (git+https://github.com/deltachat/lettre)" = "<none>"
|
||||
"checksum lettre 0.9.2 (git+https://github.com/deltachat/lettre?branch=feat/multi-auth)" = "<none>"
|
||||
"checksum lexical-core 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14"
|
||||
"checksum libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
|
||||
"checksum libm 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
|
||||
|
||||
@@ -19,7 +19,7 @@ reqwest = "0.9.15"
|
||||
num-derive = "0.2.5"
|
||||
num-traits = "0.2.6"
|
||||
native-tls = "0.2.3"
|
||||
lettre = { git = "https://github.com/deltachat/lettre" }
|
||||
lettre = { git = "https://github.com/deltachat/lettre", branch = "feat/multi-auth" }
|
||||
imap = { git = "https://github.com/dignifiedquire/rust-imap", branch = "feat/expose-read-greeting" }
|
||||
base64 = "0.10"
|
||||
charset = "0.1"
|
||||
|
||||
20
src/smtp.rs
20
src/smtp.rs
@@ -71,7 +71,7 @@ impl Smtp {
|
||||
let tls = dc_build_tls(lp.smtp_certificate_checks).unwrap();
|
||||
let tls_parameters = ClientTlsParameters::new(domain.to_string(), tls);
|
||||
|
||||
let creds = if 0 != lp.server_flags & (DC_LP_AUTH_OAUTH2 as i32) {
|
||||
let (creds, mechanism) = if 0 != lp.server_flags & (DC_LP_AUTH_OAUTH2 as i32) {
|
||||
// oauth2
|
||||
let addr = &lp.addr;
|
||||
let send_pw = &lp.send_pw;
|
||||
@@ -81,15 +81,24 @@ impl Smtp {
|
||||
}
|
||||
let user = &lp.send_user;
|
||||
|
||||
lettre::smtp::authentication::Credentials::new(
|
||||
user.to_string(),
|
||||
access_token.unwrap_or_default(),
|
||||
(
|
||||
lettre::smtp::authentication::Credentials::new(
|
||||
user.to_string(),
|
||||
access_token.unwrap_or_default(),
|
||||
),
|
||||
vec![lettre::smtp::authentication::Mechanism::Xoauth2],
|
||||
)
|
||||
} else {
|
||||
// plain
|
||||
let user = lp.send_user.clone();
|
||||
let pw = lp.send_pw.clone();
|
||||
lettre::smtp::authentication::Credentials::new(user, pw)
|
||||
(
|
||||
lettre::smtp::authentication::Credentials::new(user, pw),
|
||||
vec![
|
||||
lettre::smtp::authentication::Mechanism::Plain,
|
||||
lettre::smtp::authentication::Mechanism::Login,
|
||||
],
|
||||
)
|
||||
};
|
||||
|
||||
let security = if 0
|
||||
@@ -105,6 +114,7 @@ impl Smtp {
|
||||
let client = client
|
||||
.smtp_utf8(true)
|
||||
.credentials(creds)
|
||||
.authentication_mechanism(mechanism)
|
||||
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited);
|
||||
self.transport = Some(client.transport());
|
||||
context.call_cb(Event::SmtpConnected(format!(
|
||||
|
||||
Reference in New Issue
Block a user