How to forward emails automatically?

Hello,
I am creating for every user on my system a new email address with our own domain in mail-in-a-box. I use the curl api of mail-in-a-box for that. I would like to automatically forward the in coming emails for every user to their real original email address. I am aware of the manual approach -> going to roundcube -> settings -> filter -> redirect …

But I want to set it up automatically for every user. Is that possible? Maybe change roundcube database configuration for every user?

Tobias

Create an alias in the admin panel … (using the API)

But this is not the recommended approach as some providers (looking at you Goofle) do not respect SRS. And many other email providers (such as Yahoo!) do not allow for their emails to be forwarded - meaning that receiving servers bounce them.

https://mxroute.com/google-does-not-respect-srs-do-not-forward-email-to-google/

Ok thanks! That means even the manually email forwarding in roundcube would not work for some providers like google and yahoo?

Honestly I am not 100% certain, but most likely not. It all depends on how RC handles the forwarded email … I don’t know if it sends the email on as its own or just forwards it. If the former, it may be fine but if the latter the same applies. Honestly, you are much better off using mail fetch or similar if your email provider supports it.

Ok thank you. I am new to this topic but do you know how I can test it? How do I see at google if a email was forwarded or sent?

Forward one to your gmail account … see what happens on that end.

If you mean one that has already been forwarded you’ll need to examine the headers. Which isn’t very user friendly.

So actually even though the forwarding is configured in Roundcube, the mail rules are actually managed and executed by Dovecot (the IMAP service). Roundcube accesses the rules over the “managesieve” protocol. Other applications can too.

The forwarding that is configured in Roundcube is a proper mail forward equivalent to composing a new message, so it should not fail SPF/DMARC filtering, unlike aliases, which do in this scenario.

1 Like

Ok. Thanks! That means I have to configure Dovecot for my use case? How can I do that?

Via its sieve settings or the managesieve protocol, yep.

Thanks. I just looked into it. I have no idea…how to set this up. Do you have any good tutorials? Otherwise I will look on Upwork for developers.

I don’t have any other knowledge about it. I just know that’s where it would be. Good luck!