mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
Separate IMAP and SMTP configuration
Co-Authored-By: link2xt <ilabdsf@gmail.com> Co-Authored-By: bjoern <r10s@b44t.com>
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
//! Documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration */
|
||||
use quick_xml::events::{BytesEnd, BytesStart, BytesText};
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::login_param::LoginParam;
|
||||
use crate::provider::Socket;
|
||||
|
||||
use super::read_url::read_url;
|
||||
use super::Error;
|
||||
@@ -83,10 +83,10 @@ fn parse_xml(in_emailaddr: &str, xml_raw: &str) -> Result<LoginParam, Error> {
|
||||
buf.clear();
|
||||
}
|
||||
|
||||
if moz_ac.out.mail_server.is_empty()
|
||||
|| moz_ac.out.mail_port == 0
|
||||
|| moz_ac.out.send_server.is_empty()
|
||||
|| moz_ac.out.send_port == 0
|
||||
if moz_ac.out.imap.server.is_empty()
|
||||
|| moz_ac.out.imap.port == 0
|
||||
|| moz_ac.out.smtp.server.is_empty()
|
||||
|| moz_ac.out.smtp.port == 0
|
||||
{
|
||||
Err(Error::IncompleteAutoconfig(moz_ac.out))
|
||||
} else {
|
||||
@@ -130,37 +130,37 @@ fn moz_autoconfigure_text_cb<B: std::io::BufRead>(
|
||||
|
||||
match moz_ac.tag_server {
|
||||
MozServer::Imap => match moz_ac.tag_config {
|
||||
MozConfigTag::Hostname => moz_ac.out.mail_server = val,
|
||||
MozConfigTag::Port => moz_ac.out.mail_port = val.parse().unwrap_or_default(),
|
||||
MozConfigTag::Username => moz_ac.out.mail_user = val,
|
||||
MozConfigTag::Hostname => moz_ac.out.imap.server = val,
|
||||
MozConfigTag::Port => moz_ac.out.imap.port = val.parse().unwrap_or_default(),
|
||||
MozConfigTag::Username => moz_ac.out.imap.user = val,
|
||||
MozConfigTag::Sockettype => {
|
||||
let val_lower = val.to_lowercase();
|
||||
if val_lower == "ssl" {
|
||||
moz_ac.out.server_flags |= DC_LP_IMAP_SOCKET_SSL as i32
|
||||
moz_ac.out.imap.security = Socket::SSL;
|
||||
}
|
||||
if val_lower == "starttls" {
|
||||
moz_ac.out.server_flags |= DC_LP_IMAP_SOCKET_STARTTLS as i32
|
||||
moz_ac.out.imap.security = Socket::STARTTLS;
|
||||
}
|
||||
if val_lower == "plain" {
|
||||
moz_ac.out.server_flags |= DC_LP_IMAP_SOCKET_PLAIN as i32
|
||||
moz_ac.out.imap.security = Socket::Plain;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
MozServer::Smtp => match moz_ac.tag_config {
|
||||
MozConfigTag::Hostname => moz_ac.out.send_server = val,
|
||||
MozConfigTag::Port => moz_ac.out.send_port = val.parse().unwrap_or_default(),
|
||||
MozConfigTag::Username => moz_ac.out.send_user = val,
|
||||
MozConfigTag::Hostname => moz_ac.out.smtp.server = val,
|
||||
MozConfigTag::Port => moz_ac.out.smtp.port = val.parse().unwrap_or_default(),
|
||||
MozConfigTag::Username => moz_ac.out.smtp.user = val,
|
||||
MozConfigTag::Sockettype => {
|
||||
let val_lower = val.to_lowercase();
|
||||
if val_lower == "ssl" {
|
||||
moz_ac.out.server_flags |= DC_LP_SMTP_SOCKET_SSL as i32
|
||||
moz_ac.out.smtp.security = Socket::SSL;
|
||||
}
|
||||
if val_lower == "starttls" {
|
||||
moz_ac.out.server_flags |= DC_LP_SMTP_SOCKET_STARTTLS as i32
|
||||
moz_ac.out.smtp.security = Socket::STARTTLS;
|
||||
}
|
||||
if val_lower == "plain" {
|
||||
moz_ac.out.server_flags |= DC_LP_SMTP_SOCKET_PLAIN as i32
|
||||
moz_ac.out.smtp.security = Socket::Plain;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -314,9 +314,9 @@ mod tests {
|
||||
</webMail>
|
||||
</clientConfig>";
|
||||
let res = parse_xml("example@outlook.com", xml_raw).expect("XML parsing failed");
|
||||
assert_eq!(res.mail_server, "outlook.office365.com");
|
||||
assert_eq!(res.mail_port, 993);
|
||||
assert_eq!(res.send_server, "smtp.office365.com");
|
||||
assert_eq!(res.send_port, 587);
|
||||
assert_eq!(res.imap.server, "outlook.office365.com");
|
||||
assert_eq!(res.imap.port, 993);
|
||||
assert_eq!(res.smtp.server, "smtp.office365.com");
|
||||
assert_eq!(res.smtp.port, 587);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user