aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Fox <[email protected]>2019-01-02 22:19:44 -0500
committerNick Fox <[email protected]>2019-01-02 22:19:44 -0500
commit43eb0643511172ed8a9b134b4aca974c459e1535 (patch)
tree2970632424a81d56858d8fbc00c1436ee43c2a83
parent6e47535c2e867ecd35fb04bc37303363f8da8a24 (diff)
downloadvaultwarden-43eb0643511172ed8a9b134b4aca974c459e1535.tar.gz
vaultwarden-43eb0643511172ed8a9b134b4aca974c459e1535.zip
Replace invite/reinvite email functions with generic send_email
-rw-r--r--src/mail.rs46
1 files changed, 13 insertions, 33 deletions
diff --git a/src/mail.rs b/src/mail.rs
index 567d64ab..8e153d79 100644
--- a/src/mail.rs
+++ b/src/mail.rs
@@ -5,7 +5,6 @@ use lettre_email::EmailBuilder;
use native_tls::{Protocol, TlsConnector};
use crate::MailConfig;
-use crate::CONFIG;
use crate::api::EmptyResult;
use crate::error::Error;
@@ -67,37 +66,18 @@ pub fn send_password_hint(address: &str, hint: Option<String>, config: &MailConf
.and(Ok(()))
}
-pub fn send_invite(
- address: &str,
- org_id: &str,
- org_user_id: &str,
- token: &str,
- org_name: &str,
- config: &MailConfig,
-) -> EmptyResult {
- let (subject, body) = {
- (format!("Join {}", &org_name),
- format!(
- "<html>
- <p>You have been invited to join the <b>{}</b> organization.<br><br>
- <a href=\"{}/#/accept-organization/?organizationId={}&organizationUserId={}&email={}&organizationName={}&token={}\">Click here to join</a></p>
- <p>If you do not wish to join this organization, you can safely ignore this email.</p>
- </html>",
- org_name, CONFIG.domain, org_id, org_user_id, address, org_name, token
- ))
- };
-
+pub fn send_email(address: &str, subject: &str, body: &str, config: &MailConfig) -> EmptyResult {
let email = EmailBuilder::new()
- .to(address)
- .from((config.smtp_from.clone(), "Bitwarden-rs"))
- .subject(subject)
- .header(("Content-Type", "text/html"))
- .body(body)
- .build()
- .map_err(|e| Error::new("Error building invite email", e.to_string()))?;
+ .to(address)
+ .from((config.smtp_from.clone(), "Bitwarden-rs"))
+ .subject(subject)
+ .header(("Content-Type", "text/html"))
+ .body(body)
+ .build()
+ .map_err(|e| Error::new("Error building email", e.to_string()))?;
- mailer(config)
- .send(email.into())
- .map_err(|e| Error::new("Error sending invite email", e.to_string()))
- .and(Ok(()))
-}
+mailer(config)
+ .send(email.into())
+ .map_err(|e| Error::new("Error sending email", e.to_string()))
+ .and(Ok(()))
+} \ No newline at end of file