fix: use correct address for Bcc-self in unencrypted mails

This commit is contained in:
link2xt
2026-09-18 20:09:01 +00:00
committed by l
parent 54e16429b8
commit fae6a63023
2 changed files with 18 additions and 2 deletions

View File

@@ -431,10 +431,16 @@ pub(crate) async fn send_msg_to_smtp(
let mut recipients = queued_mail.recipients.clone();
if queued_mail.bcc_self {
let from_addr = smtp
.from
.as_ref()
.context("No From address available, likely not connected")?
.to_string();
add_self_recipients(
context,
&mut recipients,
queued_mail.encryption.is_encrypted(),
from_addr,
)
.await
.context("Failed to add self recipients")?;
@@ -703,7 +709,7 @@ async fn send_mdn_rfc724_mid(
let body = rendered_msg.message;
if context.get_config_bool(Config::BccSelf).await? {
add_self_recipients(context, &mut recipients, encrypted).await?;
add_self_recipients(context, &mut recipients, encrypted, from).await?;
}
let recipients: Vec<_> = recipients
.into_iter()
@@ -820,11 +826,11 @@ pub(crate) async fn add_self_recipients(
context: &Context,
recipients: &mut Vec<String>,
encrypted: bool,
from: String,
) -> Result<()> {
// Avoid sending unencrypted messages to all transports,
// chatmail relays won't accept them. Normally the user should have
// a non-chatmail sending transport to send unencrypted messages.
let from = context.get_primary_self_addr().await?;
if encrypted {
for addr in context.get_self_addrs().await? {
if addr != from {

View File

@@ -632,10 +632,15 @@ ORDER BY id"
.await
.expect("Failed to load queued mail");
if queued_mail.bcc_self {
let from = self
.get_primary_self_addr()
.await
.expect("Cannot get From address");
smtp::add_self_recipients(
&self.ctx,
&mut queued_mail.recipients,
queued_mail.encryption.is_encrypted(),
from,
)
.await
.expect("Failed to add self recipients");
@@ -729,10 +734,15 @@ ORDER BY id"
.await
.expect("Failed to load queued mail");
if queued_mail.bcc_self {
let from = self
.get_primary_self_addr()
.await
.expect("Cannot get self address");
smtp::add_self_recipients(
&self.ctx,
&mut queued_mail.recipients,
queued_mail.encryption.is_encrypted(),
from,
)
.await
.expect("Failed to add self recipients");