Where are message header strings stored?

This plugin allows you to report an issue in MantisBT by sending an email to a particular mail account

Moderators: Developer, Contributor

Post Reply
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Where are message header strings stored?

Post by mushu »

Mantis 2.24.0
EmailReporting 0.10.1

After a huge email system upgrade our Mantis emails are not working the way they used to. I had added custom code to several of the modules in order to look for an incoming email sender and then grab the email address from the body and use that email as the sender so that Mantis will correctly assign the Reporter via LDAP.

Everything was working until this server update. Now some of the raw message headers are missing or changed, and I can't get the emails to work properly. I need to understand several things:

#1) how the "Reporter" item in a ticket gets assigned (where is the code that does that)?
#2) where is the list of valid raw message headers the plugin uses to fill in variables such as sender and from?

Thanks!
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Where are message header strings stored?

Post by SL-Gundam »

This is the function that decides on the reporting user
https://github.com/mantisbt-plugins/Ema ... i.php#L738

Here the plugin processes various raw messages
https://github.com/mantisbt-plugins/Ema ... r.php#L323

The easiest would be to activate debug mode
It will output the raw message to raw_msg_*.txt and output the parsed message to parsed_msg_*.txt
That way you can see which headers are processed to various variables
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Where are message header strings stored?

Post by mushu »

Thank you! I had added the header "sender" to the Parser.php code and it was working fine, but now I need to add "x-sender" because our mail system removed the "sender" header. Based on if that x-sender is an email from a certain domain, I need to make the "reporter" (reported by) person be a lookup from an email address I've grabbed from the body of the email message via regex.

I'm not sure if Mantis even exposes the "x-sender" header from the message in the first place, so not sure if the EmailReporting plugin has access to it.

All of this without knowing PHP, but having been a programmer for a few decades (C, Perl, dotNet) so I feel a little handicapped not knowing the gotchas and having to look all of the functions and syntax up.

EDIT: so basically, if I can read the x-sender header value somehow, all I need to do is pass the desired email address to ldap_get_username_from_email( $p_email_address ) and it will return the username I want, then I somehow have to set the Reporter to be that user and I'm done! (Of course, there's a lot of magic hidden in that long sentence...)
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Where are message header strings stored?

Post by SL-Gundam »

Check whether its exists with empty() or isset() but yes if present the x-sender should be in $structure->headers[ 'x-sender' ]
Post Reply