rustfmt
This commit is contained in:
parent
cbe276fc06
commit
0a1631e66c
13 changed files with 766 additions and 381 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::time::Duration;
|
||||
use derive_more::Display;
|
||||
use lettre::{transport::smtp::authentication::Credentials, Message, SmtpTransport, Transport};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::consts;
|
||||
|
||||
|
|
@ -29,17 +29,29 @@ impl From<lettre::error::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn send_validation(site_url: &str, email: &str, token: &str, smtp_login: &str, smtp_password: &str) -> Result<(), Error> {
|
||||
pub fn send_validation(
|
||||
site_url: &str,
|
||||
email: &str,
|
||||
token: &str,
|
||||
smtp_login: &str,
|
||||
smtp_password: &str,
|
||||
) -> Result<(), Error> {
|
||||
let email = Message::builder()
|
||||
.message_id(None)
|
||||
.from("recipes@gburri.org".parse()?)
|
||||
.to(email.parse()?)
|
||||
.subject("Recipes.gburri.org account validation")
|
||||
.body(format!("Follow this link to confirm your inscription: {}/validation?token={}", site_url, token))?;
|
||||
.body(format!(
|
||||
"Follow this link to confirm your inscription: {}/validation?token={}",
|
||||
site_url, token
|
||||
))?;
|
||||
|
||||
let credentials = Credentials::new(smtp_login.to_string(), smtp_password.to_string());
|
||||
|
||||
let mailer = SmtpTransport::relay("mail.gandi.net")?.credentials(credentials).timeout(Some(consts::SEND_EMAIL_TIMEOUT)).build();
|
||||
let mailer = SmtpTransport::relay("mail.gandi.net")?
|
||||
.credentials(credentials)
|
||||
.timeout(Some(consts::SEND_EMAIL_TIMEOUT))
|
||||
.build();
|
||||
|
||||
if let Err(error) = mailer.send(&email) {
|
||||
eprintln!("Error when sending E-mail:\n{:?}", &error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue