switch to postmark, add starttls conf option
This commit is contained in:
parent
3e15b7b0c9
commit
a365e3cd3e
4 changed files with 20 additions and 5 deletions
|
@ -3,6 +3,8 @@ listen = "[::]:3742"
|
|||
key = "Q^,zH6M}*JY-W[oWCn6T7W!G=TvN,a5[~%cfRKZ7jse1EMDgG7GdTFy)ez*E(9I"
|
||||
|
||||
[email]
|
||||
server = "smtp.fastmail.com"
|
||||
username = "patrick@psbarrett.com"
|
||||
sender = "Z2A Bot <bot@azdle.net>"
|
||||
server = "smtp.postmarkapp.com"
|
||||
port = 587
|
||||
tls = "StartTls"
|
||||
username = "PM-T-outbound-Nh7Fw1vnQ3dwi-57cweG5e"
|
||||
sender = "Z2A Bot <bot@psbarrett.com>"
|
||||
|
|
|
@ -22,9 +22,16 @@ pub struct Email {
|
|||
pub username: String,
|
||||
pub password: String,
|
||||
pub sender: String,
|
||||
pub tls: Option<TlsMode>,
|
||||
pub cert: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub enum TlsMode {
|
||||
Tls,
|
||||
StartTls,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[allow(unused)]
|
||||
pub struct Conf {
|
||||
|
|
|
@ -11,7 +11,7 @@ use lettre::{
|
|||
};
|
||||
use tokio::time::timeout;
|
||||
|
||||
use crate::conf;
|
||||
use crate::conf::{self, TlsMode};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum EmailClient {
|
||||
|
@ -28,7 +28,12 @@ impl EmailClient {
|
|||
return Ok(EmailClient::Disabled);
|
||||
};
|
||||
|
||||
let mut inner = AsyncSmtpTransport::<Tokio1Executor>::relay(&conf.server).unwrap();
|
||||
let mut inner = match conf.tls {
|
||||
Some(TlsMode::Tls) | None => AsyncSmtpTransport::<Tokio1Executor>::relay(&conf.server)?,
|
||||
Some(TlsMode::StartTls) => {
|
||||
AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(&conf.server)?
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(port) = conf.port {
|
||||
inner = inner.port(port);
|
||||
|
|
|
@ -59,6 +59,7 @@ impl TestServer {
|
|||
username: "bot@example.com".to_owned(),
|
||||
password: "1234".to_owned(),
|
||||
sender: "bot@example.com".to_owned(),
|
||||
tls: None,
|
||||
cert: Some(String::from_utf8_lossy(mock_smtp_server.cert_pem()).to_string()),
|
||||
}),
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue