Can I use a RegEx to extract an email address and add it as a recepient?

Moderator: crythias

Post Reply
scravid
Znuny newbie
Posts: 7
Joined: 29 Apr 2016, 09:15
Znuny Version: 3.2.9
Real Name: David

Can I use a RegEx to extract an email address and add it as a recepient?

Post by scravid »

Hello all,

I've just started using OTRS after joining a new organisation so please forgive the lack of familiarity with the system!

We have a scenario whereby calls are logged by a third party on behalf of one of our users (external first line support), so currently the call appears to originate from the third party and the user has no visibility that their call has been passed to us.

What I would like to do is extract the email address from the body of the mail (it almost always comes in a pretty standard looking format with a set prefix) and add the user on as being associated with the call. I have a bit of a Regular Expression which I believe will find the email address in the body as below (thank you Google), but I'm really not sure how I would go about implementing it in my PostMaster Filters such that the result could be added as a recepient/attached to the call:

Contact Email:\*.*(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)

Can anyone provide a bit of guidance about how I might be able to do this?

Thanks a lot,

Scravid.
Charmacas
Znuny advanced
Posts: 103
Joined: 18 Jan 2016, 10:27
Znuny Version: 5.0.26 on Debian 8

Re: Can I use a RegEx to extract an email address and add it as a recepient?

Post by Charmacas »

Nice idea! My +1 for that question!
amair
Znuny newbie
Posts: 20
Joined: 17 Dec 2015, 12:48
Znuny Version: KixDesk 17
Real Name: Andreas

Re: Can I use a RegEx to extract an email address and add it as a recepient?

Post by amair »

Hi,

you could try to set the X-OTRS-CustomerUser Header to "[***]" (without quotes). "[***]" will be the part of your RegEx surrounded by "(" and ")".
This works here but we use the user's email address as "login" and "email", not sure if that is important.

BTW: you should add "a-z" to your RegEx because "A-Z" will only match uppercase.

Best regards,
Andreas
scravid
Znuny newbie
Posts: 7
Joined: 29 Apr 2016, 09:15
Znuny Version: 3.2.9
Real Name: David

Re: Can I use a RegEx to extract an email address and add it as a recepient?

Post by scravid »

Hi Andreas,

Thanks a lot for the advice - the pointer on the Regex will be very helpful indeed and I'm sure it's saved me a bunch of time!

As an OTRS newbie, how would I go about setting the X-OTRS-CustomerUser header to my regex? Sorry for the lack of understanding, I'm just beginning to find my way with the system.

Thanks again,

Scravid.

PS: Thanks for the +1 Charmacas, if I help some others while helping myself, it's all to the greater good!
amair
Znuny newbie
Posts: 20
Joined: 17 Dec 2015, 12:48
Znuny Version: KixDesk 17
Real Name: Andreas

Re: Can I use a RegEx to extract an email address and add it as a recepient?

Post by amair »

Hi Scravid,

edit your PostMaster filter. I think you already added your RegEx as filter. Now select "X-OTRS-CustomerUser" at "Set email header", use "[***]" at "Set value".

Best regards
Andreas
scravid
Znuny newbie
Posts: 7
Joined: 29 Apr 2016, 09:15
Znuny Version: 3.2.9
Real Name: David

Re: Can I use a RegEx to extract an email address and add it as a recepient?

Post by scravid »

Thanks for the very swift reply Andreas.

I'll get an try that.

I assume using this method, I'd overwrite the current X-OTRS-CustomerUser value rather than append to it?

Regards,

Scravid.
Post Reply