Added possibility to set SMTP port.

This commit is contained in:
2024-02-16 11:22:34 +01:00
parent 2907aa8ba7
commit 2d8642cb2a
3 changed files with 10 additions and 0 deletions
+5
View File
@@ -107,6 +107,11 @@ cfg_if! { if #[cfg(feature = "ssr")] {
} else {
AsyncSmtpTransport::<Tokio1Executor>::relay(&self.server().clone().unwrap_or_default())
}.expect("Cannot create SMTP mail transport");
let transport = if let Some(p) = self.port() {
transport.port(p)
} 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>,
port: Option<u16>,
user: Option<String>,
password: Option<String>,
tls: Option<bool>
@@ -84,6 +85,9 @@ impl Mailing {
pub fn server(&self) -> &Option<String> {
&self.server
}
pub fn port(&self) -> Option<u16> {
self.port
}
pub fn user(&self) -> &Option<String> {
&self.user
}