mailin icon indicating copy to clipboard operation
mailin copied to clipboard

Is it possible to forward email

Open dux opened this issue 11 years ago • 8 comments

from some accounts to some other accounts

just remark, It is really strange that you choose not to add config file for mailing, rather use super simple single route.

why not simple plain text config that would say something like

[email protected] -> http://domain1.com/mail_hook [email protected] -> http://domain1.com/mail_hook *@domain1.com -> [email protected] [email protected] -> destroy

[email protected] -> http://domain2.com/mail_hook *@domain2.com -> [email protected]

dux avatar Aug 07 '14 23:08 dux

Well that is an interesting remark. Actually there are two reasons why there is no router inside mailin:

  • The first one is that I would really like to keep the mailin core tiny and very easy to use. Today, you can use mailin without even writing a config file, that is a requirement.
  • The second reason is that I remarked that the routing can be based on complicated criteria (think a regex on the sender name for instance). So rather than defining this in a config file it is easier to post to a single route, then let the receiving webapp do the routing itself.
  • The third reason is lack of time ;-)

That said, having a powerful routing system would be awesome. This could be implemented as a separate module (mailin-router for instance or maybe we can find a better name). It would be a very simple webapp proxying post requests and forwarding emails based on the config file you described. Interesting modules to base this one are node-http-proxy and node-mailer. What do you think?

Flolagale avatar Aug 08 '14 07:08 Flolagale

Simplicity is great thing, and I am all in for that. Workflow can be that app searches for route parameter first, config file second and if nothing is found, raise error.

Regexp based routes are even better, why not :) For posting to web app, yes, but then web app is doing forwarding job that node should do better. I am strong for idea that Mailin does email routing even for multiple domains.

HTTP router is always a possibility but that adds extra layer of complexity. This problem can't be solved with node-http-proxy but node-mailer can be used for email forwarding. For a start maybe it would be best just to use simple json mapping file

{ domain1: { bot:'http://domain1.com/mail_hook', schedule:'http://domain1.com/mail_hook' '':'[email protected]' }, domain2: { bot:'http://domain1.com/mail_hook', '':'[email protected]' } }

What do you think, will you add config option? This is few hours work for you but would be great problem solver for a lot of people because you already have spam assassin integrated.

dux avatar Aug 08 '14 10:08 dux

Well the post routing should be doable. We just need to define the config file format. What you posted is a good starting point. The mail forwarding is even more interesting in my opinion, but simple-smtp does not allow inbound and outbound emails on the same machine. We have to test, but I think that we would have to use node-mailer with something else than smtp transport.

Flolagale avatar Aug 08 '14 12:08 Flolagale

Did not know that for simple-smtp restriction, but so what? We can use sendmail or postfix for outbound as we use it now and mailin for all inbound related tasks. Did I miss something?

dux avatar Aug 08 '14 13:08 dux

Agreed that this feature is needed!

2naive avatar Oct 20 '14 22:10 2naive

Sure it would be really helpful, though I'd like to take a decision on #23 before starting the dev.

Flolagale avatar Oct 21 '14 11:10 Flolagale

+1

stevenvachon avatar Jan 17 '16 17:01 stevenvachon

I love it the way it is. Allows me to write functions that send/forward email based on booleans via the Mandrill API. I'm sure you can use whatever else to forward the emails. I just think leaving it the way it is opens up more possibilities while keeping the library nice and small.

davidwieler avatar Feb 07 '16 19:02 davidwieler