0

Currently I'm struggling to achieve what sounds like a simple thing:

I have a setup with postfix, dovecot and sieve. Mails from two certain addresses to one mailbox are being forwarded to another mail address via a sieve filter, i.e. mailbox a@example.com forwards all incoming mail from 123@asd.com and 456@fgh.com to b@example.com.

This setup is working fine, but now I want to delay the forwarding of mails that arrive between 10pm and 7am – so all mails arriving in that time period are still forwarded, but not until 7am.

Does anybody know how I could achieve this?

Currently my dovecot.sieve file (generated by Roundcube Webmail SieveRules Plugin) looks something like this:

[...]

elsif allof (address :is "From" "123@asd.com",
  header :contains "Subject" "abc")
{
  redirect :copy "b@example.com";
  stop;
}

elsif allof (address :is "From" "456@fgh.com",
  header :contains "Subject" "abc")
{
  redirect :copy "b@example.com";
  stop;
}
  • One solution I was thinking about was to copy according mails into one folder and then run a script at 7am via cron that sends those mails and deletes them afterwards. But I would prefer a less "dirty" solution, of course. – David Jun 6 '17 at 13:39
0

You cannot achieve this by using sieve scripts, as those are executed while the mail arrives.

You will have to search for an option to delay the mail in your MTA, which seems to be Postfix in your case. A post on Server Fault proposes a solution using a special queue and header field (which you can set through Sieve) and modifying the Postfix configuration through cron jobs. An alternative would be to forward mails through a special Postfix instance which you either configure as described, or simply disable the smtp daemon (outgoing, not the smtpd one) during night by editing the master.cf file.

0

I've been running through a hacky solution through my head.

Basically mark it is SPAM. I recall that when setup in a certain way you could quarantine emails based on a particular rule set (SpamAssassin + Postfix). I'm saying re-write email headers within a particular time period or else write rules so that they get picked up as SPAM. This causes these emails to be quarantined. At designated times run a script to release these emails.

https://sourceforge.net/p/amavis/mailman/message/25121709/

Other option is obviously the one that you've been running through your head which involves modification of inboxes.

Another option I've been thinking about is a 'smart proxy' of some sort that sits between the MUA and the MTA or else the MTA and the Internet. Basically, it will stall Postfix with error messages until your pre-determined time. Then you flush the Postfix mail queue at that time. You may have to build it yourself though if there's nothing suitable out there.

Another option is via mail clients themselves. Once again, you may need to build a custom plugin/extension based on the situation though.

https://www.howtoforge.com/community/threads/postfix-how-to-delay-emails.54061/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.