-
Is it possible to send an email to multiple recipients? |
Beta Was this translation helpful? Give feedback.
Answered by
DK26
Apr 5, 2022
Replies: 1 comment 15 replies
-
I'm now working on a high-level facade for lettre which one of its features does exactly that. You can achieve that with lettre as you said, by using the Using lettre 0.10.0 use lettre::address::AddressError;
use lettre::message::MessageBuilder;
#[inline]
fn split(input: &str) -> impl Iterator<Item = &str> {
input
.split([',', ';'].as_ref())
.map(|part| part.trim())
.filter(|&part| !part.is_empty())
}
pub trait MultipleAddressParser {
fn to_addresses(self, addresses: &str) -> Result<MessageBuilder, AddressError>;
}
impl MultipleAddressParser for MessageBuilder {
fn to_addresses(mut self, addresses: &str) -> Result<Self, AddressError> {
for address in split(addresses) {
self = self.to(address.parse()?);
}
Ok(self)
}
} You can then use |
Beta Was this translation helpful? Give feedback.
15 replies
Answer selected by
JekRock
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm now working on a high-level facade for lettre which one of its features does exactly that. You can achieve that with lettre as you said, by using the
MessageBuilder.to
multiple times.Using lettre 0.10.0