2

We are buildng a ticket system using PHP. We have now bumped into the problem of identifying customer replies.

  • Placing an id in the subject will not do because users could remove this.
  • Posting an id in a custom header will not do because certain mail clients will remove this.
  • Posting a code in the mail body will not do either because just as with the subject, users can remove this.

We thought of placing the id in the email address. t<ticketid>@mydomain.com

However, we are not sure how to redirect this to [email protected]

2 Answers 2

2

My advice would be to use + style sub-addresses: support+<ticketid>@mydomain.example. Postfix will deliver those mails as if they were send to [email protected], ignoring the sub-address.

Postfix also allows to define a different character to be used. Set the recipient_delimiter parameter in your /etc/postfix/main.cf to the desired values:

recipient_delimiter = +-

This would allow both [email protected] and [email protected], handling both addresses in the same way.

Some Linux distributions ship postfix with recipient_delimiter set to +, so this might already work out of the box.

2

You can use the virtual_alias_maps [*]:

#virtual_alias_maps = hash:/etc/postfix/aliases
virtual_alias_maps = regexp:/etc/postfix/aliases

and fill /etc/postfix/aliases with

/t(.*)@mydomain.com/ [email protected]
/t(.*)@mydomain.com/ support+${1}@mydomain.com
/^(.*)@domain1.com$/ ${1}@domain2.com

then run command and update virtual.db

postmap /etc/postfix/virtual

you can of course fine-tune the regex to exactly match your ticketid code (ie. only numbers etc.) or use backreferences.

[*] if you don't use any virtual domains in postfix you can also use alias_maps, but how it works can sometimes be confusing, read https://serverfault.com/questions/644306/confused-about-alias-maps-and-virtual-alias-maps about it

1
  • can't edit (max 6 char changes ) but please add /^t on being when its start wit letter
    – user956584
    May 21, 2021 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .