At 12PM +1100 on 8/05/13 you (Костырев Александр Алексеевич) wrote:
I have a problem with mail redirection through sieve rules. I've configured sieve rule that redirects any mail coming to user to gmail mailbox (or whatever external mail system there is). But when sieve redirects any mail it puts vmail@%dovecot_hostname% into envelope address, gives it to my exim for delivery and gmail rejects my mail because user vmail@%dovecot_hostname% do not exist. Please, advice for what can be done about this behavior.
Sieve should be submitting the mail to the outbound SMTP with the same envelope address as it had coming in (that is, this is a true SMTP redirect, not an SPF-compatible resending-from-a-new-address). I think your SMTP server must be rewriting this based on the uid of the LDA process; this is not something Dovecot can do anything about. To test this you can run sendmail(8) with the -f switch as the vmail user: if the address you specify is rewritten, then the problem is not with Dovecot.
You need to fix this in your SMTP configuration, somehow. Decide what your policy is about the envelope sender of outbound mail: are you going to rewrite to @your.domain, which is SPF-compatible but messes up bounces; or are you going to leave it alone, which is what a sieve redirect is supposed to do but which can cause problems if the original sender publishes an SPF policy and the final recipient checks it (neither of which you can control)?
There are a number of other variously-unpleasant alternatives, like SRS (which attempts to preserve the original sender while still only sending mail from @your.domain), but basically none of this is specific to sieve or Dovecot. Find out what happens if mail is forwarded in the ordinary way by your MTA, and then work out how to get the MTA to do that for any mail submitted by the 'vmail' user.
Ben