Page 1 of 1

EmailReporting issue link URL

Posted: 01 Sep 2017, 15:39
by prash315
EmailReporting issue link URL

Postby prash315 ยป Sep 01, 2017 8:52 am
Hi,
I have setup the plugin successfully. However, when Mantis creates tickets, the email that goes out is showing the URL as localhost instead of the correct domain and context. It looks something like this

A NOTE has been added to this issue.
======================================================================
http://localhost/view.php?id=182


This is similar to the email that gets sent when a user creates an issue manually. The URL looks correct in this case

A NOTE has been added to this issue.
======================================================================
http://hostname/mantisbt/view.php?id=182

Can you please suggest me some directions here to fix this? Appreciate your help

Re: EmailReporting issue link URL

Posted: 01 Sep 2017, 18:57
by SL-Gundam
I expect you've directed the scheduled job to something like http://localhost/plugins/EmailReporting ... t_mail.php

MantisBT decides on its path everytime its run so if you run it through the localhost url, you get this result.

You have 3 options
  1. Run bug_report_mail.php through the php command line
  2. Run bug_report_mail.php through the webserver like you do know but use the same URL a normal client would use, so don't use localhost
  3. Now for this option i'm not 100% sure about the results but you can open the config_inc.php of MantisBT and force $g_path to whatever you want. This could cause unforeseen issues and could also make it more complicated to move the installation to another url in the future

Re: EmailReporting issue link URL

Posted: 01 Sep 2017, 21:35
by prash315
I actually followed the documentation and used step 1 which is recommended. I had to unblock the script from running via webserver for option 2 and that worked fine.
Also for command line, this is my batch script
cd C:\xampp\htdocs\mantis\plugins\EmailReporting\scripts
php bug_report_mail.php

I am not sure I want to use option 2, but I dont think I have a choice.. Is that correct?

Thanks
Prashanth

-------------------------------------------------------------------------------------------------------------------------------------
Setting up a scheduled / cron job for EmailReporting

EmailReporting requires that a scheduled / cron job is set up so that it can periodically retrieve emails from mailboxes

In MantisBT 1.3.x access to the plugins folder is blocked through a browser. So of the methods shown below, method 1 should be used from the command line while method 2 should be used if your hosting environment accesses the job through a webserver

/mantisbt/plugins/EmailReporting/scripts/bug_report_mail.php
/mantisbt/plugin.php?page=EmailReporting/bug_report_mail

Re: EmailReporting issue link URL

Posted: 02 Sep 2017, 16:37
by SL-Gundam
Command line:
Is there any reason you are not using command line? Doesn't it work? and if it does not work whats the problem you are running into?
On windows webserver i normally associate the php extension to the php.exe. After that i use task scheduler to run bug_report_mail.php directly like this: C:\xampp\htdocs\mantis\plugins\EmailReporting\scripts\bug_report_mail.php

Using the webserver:
Running through the webserver has disadvantages compared to command line. PHP through commandline has a longer runtime available and more memory. Memory is important as attachments can use quite a bit of it.
It does not matter whether you use localhost or the actual web address. You've already removed the protection to run the script. The only protection left is to use http://www.mantisbt.org/wiki/doku.php/m ... red_ipaddr
Why are you against option 2?

Re: EmailReporting issue link URL

Posted: 05 Sep 2017, 17:55
by prash315
The command line/task scheduling works perfectly fine. The issue is with the email that goes out to everyone. It contains an invalid link to the issue.
I tried the webserver path and that worked fine too. I was against option 2 because the documentation says not recommended. I also thought it might have security vulnerabilities, due to the fact that there is no authentication required as such. But, if I use mail_secured_ipaddr I guess we can get around that.
I want to check if anybody else has reported the issue with issue links in the email when running from command line, or is it just me due to some incorrect configuration.

Thanks
Prashanth

Re: EmailReporting issue link URL

Posted: 05 Sep 2017, 21:57
by SL-Gundam
prash315 wrote:The command line/task scheduling works perfectly fine. The issue is with the email that goes out to everyone. It contains an invalid link to the issue.
EmailReporting caches the URL and uses that when run through the commandline and therefore should not have this problem. Just make sure everything visits MantisBT through the same URL, even the stuff on the same server as MantisBT
prash315 wrote:I tried the webserver path and that worked fine too. I was against option 2 because the documentation says not recommended. I also thought it might have security vulnerabilities, due to the fact that there is no authentication required as such. But, if I use mail_secured_ipaddr I guess we can get around that.
It was not recommended to use the webserver option. Whether that is locahost or the actual URL makes not difference for the advise
prash315 wrote:I want to check if anybody else has reported the issue with issue links in the email when running from command line, or is it just me due to some incorrect configuration.
It was an issue in the past which should be fixed. If you still encounter it when using command line then its something that should be checked out
Please check the MantisBT configuration report and tell me what URL is shown for the Configuration Option 'plugin_EmailReporting_mail_mantisbt_url_fix'

Re: EmailReporting issue link URL

Posted: 06 Sep 2017, 14:17
by prash315
i dont see this variable 'plugin_EmailReporting_mail_mantisbt_url_fix' in the configuration page. Can I make one ?

Re: EmailReporting issue link URL

Posted: 06 Sep 2017, 15:28
by SL-Gundam
You could but it would not be automatically updated as it should. If you are in a hurry manually adding that variable should solve your issue

But i'd much rather find out the cause why it was not created and fix it

I've installed xampp and have reproduced the issue.
I'll let you know what i find

Re: EmailReporting issue link URL

Posted: 06 Sep 2017, 15:44
by SL-Gundam
This should do it

https://github.com/mantisbt-plugins/Ema ... e17fff3c01

Please download the latest version and let me know whether the fix also works for you

Re: EmailReporting issue link URL

Posted: 07 Sep 2017, 01:35
by prash315
I updated the line of code and looks like it has resolved the issue. I also see the variable plugin_EmailReporting_mail_mantisbt_url_fix in the configuration report page. Thank you for the quick turnaround.