Added possibility to set SMTP port.
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"
|
||||||
|
#port = 25
|
||||||
#user = "user"
|
#user = "user"
|
||||||
#password = "password"
|
#password = "password"
|
||||||
#tls = true
|
#tls = true
|
||||||
|
|||||||
@@ -107,6 +107,11 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
|||||||
} else {
|
} else {
|
||||||
AsyncSmtpTransport::<Tokio1Executor>::relay(&self.server().clone().unwrap_or_default())
|
AsyncSmtpTransport::<Tokio1Executor>::relay(&self.server().clone().unwrap_or_default())
|
||||||
}.expect("Cannot create SMTP mail transport");
|
}.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() {
|
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>,
|
||||||
|
port: Option<u16>,
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
tls: Option<bool>
|
tls: Option<bool>
|
||||||
@@ -84,6 +85,9 @@ impl Mailing {
|
|||||||
pub fn server(&self) -> &Option<String> {
|
pub fn server(&self) -> &Option<String> {
|
||||||
&self.server
|
&self.server
|
||||||
}
|
}
|
||||||
|
pub fn port(&self) -> Option<u16> {
|
||||||
|
self.port
|
||||||
|
}
|
||||||
pub fn user(&self) -> &Option<String> {
|
pub fn user(&self) -> &Option<String> {
|
||||||
&self.user
|
&self.user
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user