Skip to content

Commit

Permalink
return error is password is None
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominion5254 committed Dec 18, 2024
1 parent 115682e commit 27f7547
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions core/startos/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,20 +881,27 @@ pub async fn test_system_smtp(ctx: RpcContext, smtp: SmtpValue) -> Result<(), Er
login,
password,
} = smtp;
let message = MessageBuilder::new()
.from((from, login))
.to(vec![(from, login)])
.subject("StartOS Test Email")
.text_body("Email credentials have been successfully setup on your StartOS Server");
SmtpClientBuilder::new(server, port)
.implicit_tls(false)
.credentials((login, password.unwrap()))
.connect()
.await
.map_err(|e| Error::new(eyre!("mail-send error: {:?}", e), ErrorKind::Unknown))?
.send(message)
.await
.map_err(|e| Error::new(eyre!("mail-send error: {:?}", e), ErrorKind::Unknown))?
if let Some(pass_val) = password {
let message = MessageBuilder::new()
.from((from, login))
.to(vec![(from, login)])
.subject("StartOS Test Email")
.text_body("Email credentials have been successfully setup on your StartOS Server");
SmtpClientBuilder::new(server, port)
.implicit_tls(false)
.credentials((login, pass_val))
.connect()
.await
.map_err(|e| Error::new(eyre!("mail-send error: {:?}", e), ErrorKind::Unknown))?
.send(message)
.await
.map_err(|e| Error::new(eyre!("mail-send error: {:?}", e), ErrorKind::Unknown))?
} else {
return Error::new(
eyre!("mail-send requires a password"),
ErrorKind::IncorrectPassword,
)
}
}

#[tokio::test]
Expand Down

0 comments on commit 27f7547

Please sign in to comment.