Random delivery

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Random delivery

Jorge Bastos
Howdy,

 

I’d like to achieve something that i don’t know if it’s possible.

 

I have account [hidden email] and when an email is received, I want to
forward it to several accounts, always in this order:

 

ð  [hidden email]

ð  [hidden email]

ð  [hidden email]

 

And when it reached [hidden email] it starts again with [hidden email]

 

Would something like this be possible?

Reply | Threaded
Open this post in threaded view
|

Re: Random delivery

Aki Tuomi-2
Not sure how this is random ... =)

So you want it to deliver a the mail to first email1, next email to email2, next to email3, and next to email1.

I am pretty sure you can do this better with postfix with transport that redirects it to one of these accounts in order.

Aki

> On December 29, 2017 at 2:09 AM Jorge Bastos <[hidden email]> wrote:
>
>
> Howdy,
>
>  
>
> I’d like to achieve something that i don’t know if it’s possible.
>
>  
>
> I have account [hidden email] and when an email is received, I want to
> forward it to several accounts, always in this order:
>
>  
>
> ð  [hidden email]
>
> ð  [hidden email]
>
> ð  [hidden email]
>
>  
>
> And when it reached [hidden email] it starts again with [hidden email]
>
>  
>
> Would something like this be possible?
>
Reply | Threaded
Open this post in threaded view
|

Re: Random delivery

Joseph Tam-2
In reply to this post by Jorge Bastos
"Jorge Bastos" <[hidden email]> 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 [hidden email] and when an email is received, I want to
> forward it to several accounts, always in this order:
>
> ?  [hidden email]
> ?  [hidden email]
> ?  [hidden email]

Others have suggested a postfix method.  You can also pipe it to a script
that will select a destination to forward to alias "[hidden email]" 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 <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: Random delivery

Jorge Bastos
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:[hidden email]] On Behalf Of Joseph Tam
Sent: 30 de dezembro de 2017 07:17
To: [hidden email]
Subject: Re: Random delivery

"Jorge Bastos" <[hidden email]> 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 [hidden email] and when an email is received, I want
> to forward it to several accounts, always in this order:
>
> ?  [hidden email]
> ?  [hidden email]
> ?  [hidden email]

Others have suggested a postfix method.  You can also pipe it to a script
that will select a destination to forward to alias "[hidden email]" 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 <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: Random delivery

Andreas Born-2
In reply to this post by Jorge Bastos
Jorge Bastos wrote:

> I have account [hidden email] and when an email is received, I want to
> forward it to several accounts, always in this order:
>
> ð  [hidden email]
> ð  [hidden email]
> ð  [hidden email]
>
> And when it reached [hidden email] it starts again with [hidden email]
>
> Would something like this be possible?

If you use the sql driver for userdb lookups, you could do this by means
of your mysql lookup query. Just implement a counter and adapt the
appropriate INBOX setting für the "mail" variable in the result set.



Reply | Threaded
Open this post in threaded view
|

Re: RE: Random delivery

Jochen Bern-2
In reply to this post by Jorge Bastos
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


smime.p7s (5K) Download Attachment