Added setting for SMTP hello command.
This commit is contained in:
@@ -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?;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user