Convert generic email to the actual requester email

We are running a clean install of RT 5.0.1 with all necessary plugins, such as CommandByMail. 

We are using a web form utility that when a user submits a ticket through the form, that it goes to a email address, and we are using fetchmail to read the inbox. However, the web form utility has a "generic" email address that it puts in the from and header from fields, and apparently there is no way of changing that to make it so it essentially "spoofs" the actual requester email based off the user input in the field. 

In any event, we basically need RT to accept an email coming from "genericemail(at)" to then read the requester line in the email body to modify the requester email address in RT, so that when we reply back to the requester, it is using a real email address of the actual requester, instead of the "genericemail(at)" address.

In other words, or flow of what we are trying to accomplish:
1. User fills out Helpdesk form. (Enters name, email address, lists the problems they are having, etc into the form fields).
2. User clicks submit on the form. The form service sends the email out to the "RT(at)" as "". 
3. Fetchmail grabs the email out of the "RT(at)" email mailbox.
4. RT then processes the email, creates the ticket, and changes the requester email from "" to "legitimatemail(at)", based upon whatever the user put in the email address form field that will be put in the body of the email.

We've tried Command By Mail, and it appears like only certain commands are working, but not all. We were looking at Scrips, conditions, etc to try to accomplish this, but haven't run across any examples of this. 

Any help would be awesome!

This seems like something you can do rather easily with scrips!

Custom condition:

return unless $self->TransactionObj->Type eq 'Create';
return unless $self->TicketObj->Requestor->First->EmailAddress eq '';

Custom Action Prep:

return 1;

Custom action:

my $newRequestor = <Some code here to get the requestor address from the content of the email>;

my ($ret, $msg) = $self->TicketObj->DeleteWatcher( Email => '', Type => 'Requestor' );
RT:::Logger->error( $msg ) unless $ret;

($ret, $msg) = $self->TicketObj->AddWatcher( Email => $newRequestor, Type => 'Requestor' );
RT:::Logger->error( $msg ) unless $ret;
return $ret;

Very good.

I just have one question in regards to: “Some code here to get the requestor address from the content of the email”, what do you recommend doing here?

I’d grab the TransactionObj->Content and regex out the real requestor email address from the body of the email

Gotcha. We’ll give that whirl with a regex expression.

Try RT-Extension-ExtractCustomFieldValues
You could match the line in the body and autopopulate the requestor.
Make it an action for ‘onCreate’ in the queue in question.

Ok. We can look into that ExtractCustomFieldValues too.

Thanks for everyone’s help! Any other suggestions welcome. :slight_smile:

I have a question on the Custom action, particularly: Some code here to get the requestor address from the content of the email

We’ve tried all different regex’s and we haven’t been able to figure it out. The closest we got was using ReqEmail|Body|Email:\s*(.+), however it was throwing in extra HTML characters:<o:p></o:p>

What piece are we missing here to to just grab the without the extra HTML?

Your regex is grabbing everything “ ReqEmail|Body|Email:” you need some kind of stop delimiter in it like the “<“ html tag or something

Thanks for the Help. We got it working in a custom field, but we can’t get it working in the scrip to change the requester. If we take the regex out it compiles.

Here is a screenshot:

Here is the Custom Action Commit Code:

$newRequestor = Email:\s*([^<>/]+);
my ($ret, $msg) = $self->TicketObj->DeleteWatcher( Email => ‘notify(at)’, Type => ‘Requestor’ );
RT:::Logger->error( $msg ) unless $ret;
($ret, $msg) = $self->TicketObj->AddWatcher( Email => $newRequestor, Type => ‘Requestor’ );
RT:::Logger->error( $msg ) unless $ret;
return $ret;

Edit: We fixed the triple colons in the Custom Action Commit Code, but that still did not fix it. We even tried to run it as a batch scrip and no luck.

I’d break that regex into a stand-alone Perl script that you can run locally to check that the syntax is valid.

I don’t believe you can just have characters like you have there, maybe something like this:

my $newRequestor = (/Email:\s*([^<>\/]+)/ =~ $self->TransactionObj->Content)[1];

I didn’t try running that so its psuedo code