Added setting for SMTP hello command.

This commit is contained in:
2024-02-16 13:04:27 +01:00
parent 65e80640d5
commit af8ddc4356
3 changed files with 11 additions and 0 deletions
+1
View File
@@ -17,6 +17,7 @@ transport = "File" #or Smtp
from = "from@address.cz"
path = "Maildir"
#server = "smtp.server.cz"
#hello_name = "fqdn.server.cz"
#port = 25
#user = "user"
#password = "password"
+6
View File
@@ -17,6 +17,7 @@ cfg_if! { if #[cfg(feature = "ssr")] {
use lettre::{AsyncSmtpTransport, AsyncFileTransport, AsyncTransport, Tokio1Executor};
use lettre::transport::smtp::client::{Tls, TlsParameters};
use lettre::transport::smtp::authentication::Credentials;
use lettre::transport::smtp::extension::ClientId;
use std::ops::Add;
pub async fn message_for_type(msg_type: &MessageType, pool: &PgPool) -> Result<Message, Error> {
@@ -137,6 +138,11 @@ cfg_if! { if #[cfg(feature = "ssr")] {
} else {
transport
};
let transport = if let Some(hello) = self.hello_name() {
transport.hello_name(ClientId::Domain(hello.to_string()))
} else {
transport
};
if self.user().is_some() && self.password().is_some() {
let cred = Credentials::new(self.user().clone().unwrap(), self.password().clone().unwrap());
transport.credentials(cred).build().send(msg.build_mail(self.from().to_string())?).await?;
+4
View File
@@ -65,6 +65,7 @@ pub struct Mailing {
from: String,
path: Option<String>,
server: Option<String>,
hello_name: Option<String>,
port: Option<u16>,
user: Option<String>,
password: Option<String>,
@@ -86,6 +87,9 @@ impl Mailing {
pub fn server(&self) -> &Option<String> {
&self.server
}
pub fn hello_name(&self) -> &Option<String> {
&self.hello_name
}
pub fn port(&self) -> Option<u16> {
self.port
}