Browse Source

melib/smtp: fix Cc and Bcc ignored when sending mail

master
Manos Pitsidianakis 1 month ago
parent
commit
ffc498a5d0
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 8
      melib/src/email.rs
  2. 8
      melib/src/smtp.rs

8
melib/src/email.rs

@ -488,6 +488,14 @@ impl Envelope {
self.to.as_slice()
}
pub fn cc(&self) -> &[Address] {
self.cc.as_slice()
}
pub fn bcc(&self) -> &[Address] {
self.bcc.as_slice()
}
pub fn field_to_to_string(&self) -> String {
if self.to.is_empty() {
self.other_headers

8
melib/src/smtp.rs

@ -616,7 +616,7 @@ impl SmtpConnection {
let envelope = Envelope::from_bytes(mail.as_bytes(), None)
.chain_err_summary(|| "SMTP submission was aborted")?;
let tos = tos.unwrap_or_else(|| envelope.to());
if tos.is_empty() {
if tos.is_empty() && envelope.cc().is_empty() && envelope.bcc().is_empty() {
return Err(MeliError::new("SMTP submission was aborted because there was no e-mail address found in the To: header field. Consider adding recipients."));
}
let mut current_command: SmallVec<[&[u8]; 16]> = SmallVec::new();
@ -651,7 +651,11 @@ impl SmtpConnection {
//return a reply indicating whether the failure is permanent (i.e., will occur again if
//the client tries to send the same address again) or temporary (i.e., the address might
//be accepted if the client tries again later).
for addr in tos {
for addr in tos
.into_iter()
.chain(envelope.cc().into_iter())
.chain(envelope.bcc().into_iter())
{
current_command.clear();
current_command.push(b"RCPT TO:<");
current_command.push(addr.address_spec_raw().trim());

Loading…
Cancel
Save