Redirect Incoming Mail Script

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
jsmith
New user
New user
Posts: 4
Joined: 2019-04-12 05:47

Redirect Incoming Mail Script

Post by jsmith » 2019-04-12 05:59

I am new to hMail and hoping someone can help me out. I'd like to set up a script to handle incoming mail as follows:

Emails will arrive with a prefix in front of the real username. For example, an email will arrive addressed to "23.jsmith@mail.com". I'd like to have a script that will direct that email to the "root" email address (in this case it will direct that email to the mailbox of "jsmith@mail.com".

Can someone please provide me with some guidance on this?

Any assistance would be appreciated.

User avatar
mattg
Moderator
Moderator
Posts: 19513
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Redirect Incoming Mail Script

Post by mattg » 2019-04-12 07:13

Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
SorenR
Senior user
Senior user
Posts: 2907
Joined: 2006-08-21 15:38
Location: Denmark

Re: Redirect Incoming Mail Script

Post by SorenR » 2019-04-12 07:33

mattg wrote:
2019-04-12 07:13
See 'Plus addressing' here >> https://www.hmailserver.com/documentati ... nce_domain
That won't work. Wrong order of username and "tag".

Maybe something like this... https://www.hmailserver.com/forum/viewt ... 20&t=29306
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

jsmith
New user
New user
Posts: 4
Joined: 2019-04-12 05:47

Re: Redirect Incoming Mail Script

Post by jsmith » 2019-04-12 15:06

Thanks for suggestions. That last one is interesting, however, that is set up for all incoming emails to be directed to one email account. I'd like to set something up in which we will have multiple users. The incoming mail would be directed based on the "root" email address. For example, email addressed to "23.user1@mail.com" would be put in user1's emailbox, and email addressed to "23.user2@mail.com" would be put in user2's emailbox, etc...

Can this be done with rules?

Thanks for any ideas...

User avatar
SorenR
Senior user
Senior user
Posts: 2907
Joined: 2006-08-21 15:38
Location: Denmark

Re: Redirect Incoming Mail Script

Post by SorenR » 2019-04-12 15:35

jsmith wrote:
2019-04-12 15:06
Thanks for suggestions. That last one is interesting, however, that is set up for all incoming emails to be directed to one email account. I'd like to set something up in which we will have multiple users. The incoming maul would be directed based on the "root" email address. For example, email addressed to "23.user1@mail.com" would be put in user1's emailbox, and email addressed to "23.user2@mail.com" would be put in user2's emailbox, etc...

Can this be done with rules?

Thanks for any ideas...
If you look at "Plus Addressing" you will find what you are looking for, with one execption. It's reversed and only "+", "-", "_" and "%" is supported.

You'll find it here: hMailAdmin --> Domains --> <your domain>[Advanced]

If enabled and configured for e.g. "_" all emails to john_doe@acme.inc, john_wick@acme.inc and john_kerry@acme.inc all go to john@acme.inc.

If you insist on your current layout, it can be done but due to a bug (?) or unforseen feature in the "CatchAll" handling you may loose emails.
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

User avatar
jimimaseye
Moderator
Moderator
Posts: 7824
Joined: 2011-09-08 17:48

Re: Redirect Incoming Mail Script

Post by jimimaseye » 2019-04-12 19:55

jsmith wrote:
2019-04-12 15:06
Thanks for suggestions. That last one is interesting, however, that is set up for all incoming emails to be directed to one email account. I'd like to set something up in which we will have multiple users. The incoming mail would be directed based on the "root" email address. For example, email addressed to "23.user1@mail.com" would be put in user1's emailbox, and email addressed to "23.user2@mail.com" would be put in user2's emailbox, etc...

Can this be done with rules?

Thanks for any ideas...
With the script that was posted/referred to you can yes. All inbound emails hitting the 'catchall' (root) scenario will be sent to that one account. But then you set up rules in the root account (or a handling script) similar to

if TO contains 'user1@' then forward to user1
if TO contains 'user2@' then forward to user2
etc

Tested.

I use that script and its very useful for these things. (And the blocklist is good - you could just disable "23.user1@" just by adding it to the rejection list).
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

jsmith
New user
New user
Posts: 4
Joined: 2019-04-12 05:47

Re: Redirect Incoming Mail Script

Post by jsmith » 2019-04-13 06:10

That may work. I'll play around with that.

Thanks for the suggestion!

User avatar
jimimaseye
Moderator
Moderator
Posts: 7824
Joined: 2011-09-08 17:48

Re: Redirect Incoming Mail Script

Post by jimimaseye » 2019-04-13 09:48

Quote from the guide:
jimimaseye wrote:
2016-02-29 13:19
If you would like the emails to be further filtered and distributed to various internal users based on the incoming email address (so that they don't all appear in the single nominated main 'catchall' account), then you can use RULES within HMS to forward the emails accordingly. You may find this thread here with useful tips on using REGEXP to manage this easily.
[Entered by mobile. Excuse my spelling.]
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

jsmith
New user
New user
Posts: 4
Joined: 2019-04-12 05:47

Re: Redirect Incoming Mail Script

Post by jsmith » 2019-04-14 03:10

Ok, got it installed and configured. That looks like that will work well!

Many thanks Jimimasey. Now I need to put something together to send emails from those "Disposable addresses...

Post Reply