Added setting for SMTP hello command.
This commit is contained in:
@@ -17,6 +17,7 @@ transport = "File" #or Smtp
|
|||||||
from = "from@address.cz"
|
from = "from@address.cz"
|
||||||
path = "Maildir"
|
path = "Maildir"
|
||||||
#server = "smtp.server.cz"
|
#server = "smtp.server.cz"
|
||||||
|
#hello_name = "fqdn.server.cz"
|
||||||
#port = 25
|
#port = 25
|
||||||
#user = "user"
|
#user = "user"
|
||||||
#password = "password"
|
#password = "password"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
|||||||
use lettre::{AsyncSmtpTransport, AsyncFileTransport, AsyncTransport, Tokio1Executor};
|
use lettre::{AsyncSmtpTransport, AsyncFileTransport, AsyncTransport, Tokio1Executor};
|
||||||
use lettre::transport::smtp::client::{Tls, TlsParameters};
|
use lettre::transport::smtp::client::{Tls, TlsParameters};
|
||||||
use lettre::transport::smtp::authentication::Credentials;
|
use lettre::transport::smtp::authentication::Credentials;
|
||||||
|
use lettre::transport::smtp::extension::ClientId;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
pub async fn message_for_type(msg_type: &MessageType, pool: &PgPool) -> Result<Message, Error> {
|
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 {
|
} else {
|
||||||
transport
|
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() {
|
if self.user().is_some() && self.password().is_some() {
|
||||||
let cred = Credentials::new(self.user().clone().unwrap(), self.password().clone().unwrap());
|
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?;
|
transport.credentials(cred).build().send(msg.build_mail(self.from().to_string())?).await?;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ pub struct Mailing {
|
|||||||
from: String,
|
from: String,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
server: Option<String>,
|
server: Option<String>,
|
||||||
|
hello_name: Option<String>,
|
||||||
port: Option<u16>,
|
port: Option<u16>,
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
@@ -86,6 +87,9 @@ impl Mailing {
|
|||||||
pub fn server(&self) -> &Option<String> {
|
pub fn server(&self) -> &Option<String> {
|
||||||
&self.server
|
&self.server
|
||||||
}
|
}
|
||||||
|
pub fn hello_name(&self) -> &Option<String> {
|
||||||
|
&self.hello_name
|
||||||
|
}
|
||||||
pub fn port(&self) -> Option<u16> {
|
pub fn port(&self) -> Option<u16> {
|
||||||
self.port
|
self.port
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user