mirror of
https://github.com/soywod/himalaya.git
synced 2025-04-22 17:23:27 +00:00
build smtp envelope after executing pre_send hook
This commit is contained in:
parent
4dc1be25cd
commit
3899ec9c03
1 changed files with 14 additions and 10 deletions
|
@ -56,18 +56,22 @@ impl LettreService<'_> {
|
|||
|
||||
impl SmtpService for LettreService<'_> {
|
||||
fn send(&mut self, account: &AccountConfig, msg: &Msg) -> Result<Vec<u8>> {
|
||||
let envelope: lettre::address::Envelope = msg.try_into()?;
|
||||
let mut msg = msg.into_sendable_msg(account)?.formatted();
|
||||
let mut raw_msg = msg.into_sendable_msg(account)?.formatted();
|
||||
|
||||
if let Some(cmd) = account.hooks.pre_send.as_deref() {
|
||||
for cmd in cmd.split('|') {
|
||||
msg = pipe_cmd(cmd.trim(), &msg)
|
||||
.with_context(|| format!("cannot execute pre-send hook {:?}", cmd))?
|
||||
}
|
||||
};
|
||||
let envelope: lettre::address::Envelope =
|
||||
if let Some(cmd) = account.hooks.pre_send.as_deref() {
|
||||
for cmd in cmd.split('|') {
|
||||
raw_msg = pipe_cmd(cmd.trim(), &raw_msg)
|
||||
.with_context(|| format!("cannot execute pre-send hook {:?}", cmd))?
|
||||
}
|
||||
let parsed_mail = mailparse::parse_mail(&raw_msg)?;
|
||||
Msg::from_parsed_mail(parsed_mail, account)?.try_into()
|
||||
} else {
|
||||
msg.try_into()
|
||||
}?;
|
||||
|
||||
self.transport()?.send_raw(&envelope, &msg)?;
|
||||
Ok(msg)
|
||||
self.transport()?.send_raw(&envelope, &raw_msg)?;
|
||||
Ok(raw_msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue