Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with re-writing email headers #7

Open
francoislepage opened this issue Aug 5, 2018 · 6 comments
Open

Help with re-writing email headers #7

francoislepage opened this issue Aug 5, 2018 · 6 comments

Comments

@francoislepage
Copy link

Hi,

Congratulations and thank you for making this plugin available. :-)

I am trying to use it to rewrite the email headers of emails containing a voicemail as an mp3 attachment, using the RegEx rewriter.

The following headers are inserted in the original email being sent to osTicket :

X-Asterisk-CallerID: 5142224444
X-Asterisk-CallerIDName: FirstName LastName

I though I would match them, and replace them with a Reply-To header such as
Reply-to: "FirstName LastName" <sms+5142224444@myvoipprovider.net>

..knowing that I configured osTicket to use the Reply-To information.

Here is the $pattern, $replacement I am using :

/X-Asterisk-CallerID:\s(\d{10})\nX-Asterisk-CallerIDName:\s(.+)$/m||Reply-To: "$2" <sms+$1@myvoipprovider>

Since I am trying to match headers and that the ":" separator was in my way, I did edit config.php and class.RewriterPlugin.php to use "||" as a separator, which seem to work, since "the confirmation message in the admin panel reports $pattern and $replacement properly". I do have to set <, > " using html escape characters.

I can confirm the plugin runs because I can re-write emails addresses properly (non-regex).

I'm not sure what I am missing here, but I do not get any system logs, debug traces, etc, when only using the RegEx replacement.

My RegEx and replacement were tested successfully outside of the plugin. I'm wondering if the issue has something to do with me trying to perform a multi-line match /m,

Your insights on this would be greatly appreciated.

Thank you

@francoislepage
Copy link
Author

francoislepage commented Aug 5, 2018

While performing more troubleshoot, I noticed the following logs :

In Apache error logs
[Sun Aug 05 14:40:22.743053 2018] [proxy_fcgi:error] [pid 10267:tid 139895850878720] [client 192.xxx.xxx.xxx:0] AH01071: Got error 'PHP message: osTicket RewritePlugin: Bootstrappin..\n', referer: https://help.mydomain.com/scp/tickets.php

In osTicket
Going to get brutal with regex against the ticket.. hold onto your hat!

The last one being quite humorous. This was after enabling : DUMPWHOLETHING

@clonemeagain
Copy link
Owner

Hmm, others have tried the regex thing as well, it's complex. I'd suggest the easiest for that is to actually add a custom method to the plugin.
Does osTicket even use the Reply-To address? hmm.

@francoislepage
Copy link
Author

Hi,

Yes, osTicket have an option to use the Reply-To instead of the regular header as part of the filter system. I'm not sure thought is this would work with your code Regardless, we ended up deciding on developing a custom function that will extract and use the right headers.

Thank you for your answer!

@clonemeagain
Copy link
Owner

Ok, if you want to submit it as a pull request others might appreciate it mate. But either way, glad it works. 🙂

@francoislepage
Copy link
Author

I am not developing it myself, I asked for help and development did not start yet. I'm not sure if integration with plugin-fwd-rewriter will be straight forward, but if there is something I can share, I will definitely do so.

Kind regards,

@clonemeagain
Copy link
Owner

clonemeagain commented Aug 22, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
-