Fix send email request body

This commit is contained in:
Alphonse Paix
2025-08-25 18:51:37 +02:00
parent 5a86d7a35f
commit fccb79c57f
3 changed files with 19 additions and 9 deletions

View File

@@ -32,8 +32,12 @@ impl EmailClient {
) -> Result<(), reqwest::Error> {
let url = self.base_url.join("v1/email").unwrap();
let request_body = SendEmailRequest {
from: self.sender.as_ref(),
to: vec![recipient.as_ref()],
from: EmailField {
email: self.sender.as_ref(),
},
to: vec![EmailField {
email: recipient.as_ref(),
}],
subject,
text: text_content,
html: html_content,
@@ -56,13 +60,18 @@ impl EmailClient {
#[derive(serde::Serialize)]
struct SendEmailRequest<'a> {
from: &'a str,
to: Vec<&'a str>,
from: EmailField<'a>,
to: Vec<EmailField<'a>>,
subject: &'a str,
text: &'a str,
html: &'a str,
}
#[derive(serde::Serialize)]
struct EmailField<'a> {
email: &'a str,
}
#[cfg(test)]
mod tests {
use std::time::Duration;