✨ (mail): Marca los correos como automáticos
Por defecto, los correos llevan `Auto-Submitted: auto-generated` (RFC 3834) para no recibir avisos de ausencia; `with_auto_submitted(false)` la quita en los que escribe una persona. Añade SentEmail::links() para seguir en las pruebas los enlaces de los correos.
This commit is contained in:
parent
3c6dea9728
commit
d7caf724dd
3 changed files with 110 additions and 4 deletions
|
|
@ -109,6 +109,9 @@ async fn text_email_uses_default_sender_and_reaches_every_recipient() {
|
|||
.any(|line| line.starts_with("Message-ID: <") && line.ends_with("@example.com>")),
|
||||
"Message-ID must use the sender domain"
|
||||
);
|
||||
// Marks the email as automatic so that out-of-office replies are not sent back.
|
||||
assert!(sent.email().auto_submitted());
|
||||
assert!(sent.raw().contains("Auto-Submitted: auto-generated\r\n"));
|
||||
assert!(sent.raw().contains("Content-Type: text/plain"));
|
||||
// Bcc recipients get the email but must not appear in its headers.
|
||||
assert!(!sent.raw().contains("text-bcc@example.com"));
|
||||
|
|
@ -190,6 +193,42 @@ async fn html_document_is_sent_without_layout() {
|
|||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn auto_submitted_header_can_be_left_out() {
|
||||
// E.g. a contact form message: some help desks suspend or reject automatic emails.
|
||||
let sent = send_one(
|
||||
Email::new()
|
||||
.with_to("human@example.com")
|
||||
.with_text("Written by a person")
|
||||
.with_auto_submitted(false),
|
||||
"human@example.com",
|
||||
)
|
||||
.await;
|
||||
assert!(!sent.raw().contains("Auto-Submitted"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn links_are_extracted_unescaped_in_order() {
|
||||
let sent = send_one(
|
||||
Email::new()
|
||||
.with_to("links@example.com")
|
||||
.with_html_document(html! {
|
||||
html { body {
|
||||
a href="https://example.com/a?x=1&y=2" { "First" }
|
||||
// Other attributes ending in "href" are not links.
|
||||
a data-href="https://example.com/no" href="https://example.com/b" { "Second" }
|
||||
} }
|
||||
}),
|
||||
"links@example.com",
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
sent.links(),
|
||||
["https://example.com/a?x=1&y=2", "https://example.com/b"]
|
||||
);
|
||||
}
|
||||
|
||||
// **< Attachments >********************************************************************************
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue