melib/smtp: fix Cc and Bcc ignored when sending mail
parent
d25eb00a11
commit
ffc498a5d0
|
@ -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
|
||||
|
|
|
@ -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…
Reference in New Issue