|
|
@ -36,17 +36,23 @@ fn mailer(config: &MailConfig) -> SmtpTransport {
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn send_password_hint(address: &str, hint: &str, config: &MailConfig) -> Result<(), String> {
|
|
|
|
pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConfig) -> Result<(), String> {
|
|
|
|
let body = format!(
|
|
|
|
let (subject, body) = if let Some(hint) = hint {
|
|
|
|
"You (or someone) recently requested your master password hint.\n\n\
|
|
|
|
("Your master password hint",
|
|
|
|
Your hint is: \"{}\"\n\n\
|
|
|
|
format!(
|
|
|
|
If you did not request your master password hint you can safely ignore this email.\n",
|
|
|
|
"You (or someone) recently requested your master password hint.\n\n\
|
|
|
|
hint);
|
|
|
|
Your hint is: \"{}\"\n\n\
|
|
|
|
|
|
|
|
If you did not request your master password hint you can safely ignore this email.\n",
|
|
|
|
|
|
|
|
hint))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
("Sorry, you have no password hint...",
|
|
|
|
|
|
|
|
"Sorry, you have not specified any password hint...\n".to_string())
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let email = EmailBuilder::new()
|
|
|
|
let email = EmailBuilder::new()
|
|
|
|
.to(address)
|
|
|
|
.to(address)
|
|
|
|
.from((config.smtp_from.to_owned(), "Bitwarden-rs"))
|
|
|
|
.from((config.smtp_from.to_owned(), "Bitwarden-rs"))
|
|
|
|
.subject("Your Master Password Hint")
|
|
|
|
.subject(subject)
|
|
|
|
.body(body)
|
|
|
|
.body(body)
|
|
|
|
.build().unwrap();
|
|
|
|
.build().unwrap();
|
|
|
|
|
|
|
|
|
|
|
@ -55,4 +61,3 @@ pub fn send_password_hint(address: &str, hint: &str, config: &MailConfig) -> Res
|
|
|
|
Err(e) => Err(e.description().to_string()),
|
|
|
|
Err(e) => Err(e.description().to_string()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|