"Jorge Bastos" <mysql.jorge at decimal.pt> writes:> I?d like to achieve something that i don?t know if it?s possible.It's almost always possible; it really depends on how much work you want to do.> I have account info at domain.tld and when an email is received, I want to > forward it to several accounts, always in this order: > > ? Email1 at domain.tlf > ? Email2 at domain.tld > ? Email3 at domain.tldOthers have suggested a postfix method. You can also pipe it to a script that will select a destination to forward to alias "info at domain.tld" to "|/my/selector|script". This will work both in Postfix, sendmail, and probably most other MTAs. If you actually want randomization (rather than sequential round-robin), you can simplify because you won't need to record the last delivery. Use /dev/urandom or unix time() mod 3 to select forwarding address. Joseph Tam <jtam.home at gmail.com>
Hi Joseph, It's that what I want!! Sequentially, my bad saying random! Well... with the script, I remember I did something like this 15 years ago with qmail with a php script, that every email was saved in mysql and I always selected the next email addrr in the list. Going to search for this option in postfix, thanks for the tip as this is a bit offtopic of dovecot, -----Original Message----- From: dovecot [mailto:dovecot-bounces at dovecot.org] On Behalf Of Joseph Tam Sent: 30 de dezembro de 2017 07:17 To: dovecot at dovecot.org Subject: Re: Random delivery "Jorge Bastos" <mysql.jorge at decimal.pt> writes:> I?d like to achieve something that i don?t know if it?s possible.It's almost always possible; it really depends on how much work you want to do.> I have account info at domain.tld and when an email is received, I want > to forward it to several accounts, always in this order: > > ? Email1 at domain.tlf > ? Email2 at domain.tld > ? Email3 at domain.tldOthers have suggested a postfix method. You can also pipe it to a script that will select a destination to forward to alias "info at domain.tld" to "|/my/selector|script". This will work both in Postfix, sendmail, and probably most other MTAs. If you actually want randomization (rather than sequential round-robin), you can simplify because you won't need to record the last delivery. Use /dev/urandom or unix time() mod 3 to select forwarding address. Joseph Tam <jtam.home at gmail.com>
On 12/31/2017 01:30 PM, Jorge Bastos wrote:> It's that what I want!! > Sequentially, my bad saying random!The trickier parts of coding LDAs - with locking/semaphores and such - address the case of *(near) simultaneous* arrival of e-mails. In your case, you wouldn't need to lock "the mailbox" (if info@ even *has* one) but wherever the info "which address did we *last* forward to?" is stored. Do you actually need 100% correctness (a. of sequential selection, or at least b. of even distribution with 33% each) in that corner case? It's not like Received: headers would usually include timestamps with subsecond precision to base a retrospect analysis on ... (Out of interest, if someone were to send an e-mail to you - say, order something from your company - and sends a reply-to-all to his own copy before anyone answered the original mail - say, "oops, I forgot to tell you the delivery address, here it is" -, do you really want those two mails to go to *different* recipients with 66+% probability?) I'ld guess that such a function can be had in the final MTA, in dovecot acting as MDA, in the alias-resolving mechanism (if separate), maybe even in the mechanism generating out-of-office autoreplies (if tweakable). Deciding which route would be the *easiest* to take requires more details of your setup, though ... Kind regards, -- Jochen Bern Systemingenieur www.binect.de -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4278 bytes Desc: S/MIME Cryptographic Signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20180101/53301efc/attachment.p7s>