Quelques corrections
This commit is contained in:
parent
b912f9140e
commit
fc65a4069d
4 changed files with 472 additions and 391 deletions
814
Cargo.lock
generated
814
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
lettre = "0.10"
|
lettre = "0.10"
|
||||||
toml = "0.5"
|
toml = "0.7"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
simplelog = "0.12"
|
simplelog = "0.12"
|
||||||
|
|
3
TODO.md
3
TODO.md
|
@ -4,4 +4,5 @@
|
||||||
* [ ] Rustfmt
|
* [ ] Rustfmt
|
||||||
* [ ] Logs tournant
|
* [ ] Logs tournant
|
||||||
* [ ] Fonction check asychrone
|
* [ ] Fonction check asychrone
|
||||||
* [ ] Utilisation de l’[API Gandi](https://api.gandi.net/docs/livedns) via [restson](https://crates.io/crates/restson)
|
* [ ] Utilisation de https://crates.io/crates/public-ip ?
|
||||||
|
* [ ] Test automatique avec mailin-embedded
|
20
src/main.rs
20
src/main.rs
|
@ -199,13 +199,12 @@ impl Tester {
|
||||||
fn send_mail(&self, subject: String, body: String) -> Result<()> {
|
fn send_mail(&self, subject: String, body: String) -> Result<()> {
|
||||||
info!("Send mail {}", subject);
|
info!("Send mail {}", subject);
|
||||||
|
|
||||||
if let Some(false) = self.config.test {
|
|
||||||
let email = Message::builder()
|
let email = Message::builder()
|
||||||
.to(Mailbox::new(
|
.from(Mailbox::new(
|
||||||
Some(self.config.mail.from.1.clone()),
|
Some(self.config.mail.from.1.clone()),
|
||||||
self.config.mail.from.0.parse::<Address>()?,
|
self.config.mail.from.0.parse::<Address>()?,
|
||||||
))
|
))
|
||||||
.from(self.config.mail.to.parse()?)
|
.to(self.config.mail.to.parse()?)
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.body(body)?;
|
.body(body)?;
|
||||||
|
|
||||||
|
@ -215,17 +214,20 @@ impl Tester {
|
||||||
self.config.mail.password.clone(),
|
self.config.mail.password.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open a remote connection to gmail
|
// Open a remote connection
|
||||||
let mailer = SmtpTransport::relay(&self.config.mail.server)
|
let mailer = if let Some(true) = self.config.test {
|
||||||
|
SmtpTransport::builder_dangerous(&self.config.mail.server)
|
||||||
|
.port(self.config.mail.port)
|
||||||
|
.build()
|
||||||
|
} else {
|
||||||
|
SmtpTransport::relay(&self.config.mail.server)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.credentials(creds)
|
.credentials(creds)
|
||||||
.port(self.config.mail.port)
|
.port(self.config.mail.port)
|
||||||
.build();
|
.build()
|
||||||
|
};
|
||||||
|
|
||||||
mailer.send(&email)?;
|
mailer.send(&email)?;
|
||||||
} else {
|
|
||||||
println!("subject: {} - body: {}", subject, body);
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue