Cleaning
This commit is contained in:
parent
198bff6e4a
commit
6f014ef238
19 changed files with 118 additions and 81 deletions
|
|
@ -4,7 +4,6 @@ use lettre::{
|
|||
AsyncTransport, Message, Tokio1Executor,
|
||||
transport::smtp::{AsyncSmtpTransport, authentication::Credentials},
|
||||
};
|
||||
use tracing::error;
|
||||
|
||||
use crate::consts;
|
||||
|
||||
|
|
@ -22,7 +21,13 @@ pub enum Error {
|
|||
|
||||
#[async_trait::async_trait]
|
||||
pub trait EmailServiceTrait: Send + Sync {
|
||||
async fn send_email(&self, email: &str, title: &str, message: &str) -> Result<(), Error>;
|
||||
async fn send_email(
|
||||
&self,
|
||||
email_sender: &str,
|
||||
email_receiver: &str,
|
||||
title: &str,
|
||||
message: &str,
|
||||
) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
pub struct EmailService {
|
||||
|
|
@ -49,11 +54,17 @@ impl EmailService {
|
|||
impl EmailServiceTrait for EmailService {
|
||||
/// A function to send an email using the given SMTP address.
|
||||
/// It may timeout if the SMTP server is not reachable, see [consts::SEND_EMAIL_TIMEOUT].
|
||||
async fn send_email(&self, email: &str, title: &str, message: &str) -> Result<(), Error> {
|
||||
async fn send_email(
|
||||
&self,
|
||||
email_sender: &str,
|
||||
email_receiver: &str,
|
||||
title: &str,
|
||||
message: &str,
|
||||
) -> Result<(), Error> {
|
||||
let email = Message::builder()
|
||||
.message_id(None)
|
||||
.from(consts::EMAIL_ADDRESS.parse()?)
|
||||
.to(email.parse()?)
|
||||
.from(email_sender.parse()?)
|
||||
.to(email_receiver.parse()?)
|
||||
.subject(title)
|
||||
.body(message.to_string())?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue