Email output could be much prettier

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

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

Email output could be much prettier

Post by mushu »

Wondering if it is possible to allow the email output from MantisBT to be template-driven? It would be great to allow embedded variables that get data substituted at send time for things like customer name and subject and notes, etc to be able to place them where we want them in the output. Plus use CSS and make it pretty for the end user. Our users have frequently told us that they don't bother to scroll down through the long notification emails because they are hard to read and they can't find the information they need without a lot of time. They are not computer people and can't just visually skim over things that developers automatically ignore.

I've brought this up previously and got an answer like "Well, we've done MantisBT for years and have never heard anyone complain so won't put this on the list." It's possible that people are resigned that it will never get nicer to read so they simply don't say anything. I'm aware that there was briefly an attempt to change a lot of the code to do exactly this, but after a few updates it became unwieldy to maintain, and as far as I know it got dropped.

I would love to see this added as a future code enhancement because I don't think it can be a plugin due to how the MantisBT email system works, but I could be wrong. To be able to build an email output template that has italic/bold/underlined text, colors, images, HTML support, etc would be wonderful and would set MantisBT up a notch because UI is a very important thing for ADA/accessibility and that includes program output.
Last edited by mushu on 05 Oct 2020, 23:37, edited 1 time in total.
Starbuck
Posts: 219
Joined: 14 Feb 2006, 02:53
Location: USA
Contact:

Re: Email output could be much prettier

Post by Starbuck »

I've brought this up previously and got an answer like "Well, we've done MantisBT for years and have never heard anyone complain so won't put this on the list."
I get really aggravated with responses like that too. They discourage innovation and user engagement.
HOWEVER, for this specific enhancement I don't think that has been the official response, and we don't see that kind of response here often at all except for very nuanced requests. But this request is indeed reasonable and popular.
It's possible that people are resigned that it will never get nicer to read so they simply don't say anything.
You're touching on two good points.

Resignation implies that someone knows that a request has been made and not processed. But most people don't take it that far, they simply don't make the request. They don't bother to provide feedback. For every one person who adds a +1 to a request there are a lot who do not. But this project doesn't make it easy to +1 changes either. You need to login to the tracker, find the ticket you're interested in, and simply subscribe to notifications or add a +1 comment. So we have a self-fulfulling cycle: People can't vote for a change, so we don't see a lot of demand in the tracker for specific changes. THAT is when the devs say "there isn't enough demand so we won't process it".

OK, now we're onto your second point, that people who DO make a request come back over and over to find that many tickets are left in New status for years, not even given the benefit of an Acknowledged status or Confirmed. To me, that's insulting. It's infuriating when it looks like a lot of people ask for something in tickets and forums, and it's not even given consideration. Reject it. Process it. I don't care. Just don't make me feel like my voice is being ignored.

HOWEVER, while that's the way I sometimes feel, I know that's not how things work here. Devs DO read and consider the requests. They just don't take the time to change the status. And considering all of the time that I sincerely appreciate that they put into this fine software, personally I cut them some slack.

So once again, I recognize the sentiment that drives people to resignation, but I know it's not intended by this team and I think it's unfortunate that there isn't someone doing "social triage" here to ensure people know that their voices are heard.
I'm aware that there was briefly an attempt to change a lot of the code to do exactly this, but ... as far as I know it got dropped.
I know a few attempts at this have been made. I took a shot at this myself. It looks simple to start changing the one file that creates the email. But then it starts getting messy. The thing is, once we try it the easy way and it doesn't work, some respect for the code needs to kick in - we can't assume this is going to be easy and then just drop it when it's not. We need to recognize that this bit of code is as serious as any other. In short, email should be created just like a web page, using a template system which can then be themed. There are two parts to this, content, and presentation. So a site should be able to change what goes into the email using flags, and then change how it looks with themes. That requires an enhancement to the managerment UI. As you see this becomes more than just a simple change.

I think getting this change is a simple matter of priority. I really do not like the emails from this system either, but if I have a choice between something looking pretty and something not working right, I'm going with functionality every time. From what I've seen, the priority in this package is with security first, then bugs, then functionality, and far later we find enhancements to email presentation and other such cosmetics.

<preach mode=on> Note that this is not directed at any person - it's general commentary.

The way we will get this change and pretty much any other change in any FOSS is as follows:

Someone who works at a company needs to get a complaint from someone in management that the emails are ugly and need to be fixed.

I.T. people there need to tell them that the software is free (libre+beer) but they'll only get changes THEY want if they provide to a developer what HE wants. You're free to make your own changes. If you choose not to do so, offer someone some coffee or donuts or pizza or money or a day at DisneyLand - but offer something in exchange for what you value. Business is transactional. A business needs to spend money to earn more money. A company might spend a hundred thousand dollars on some ERP package but then insist on getting their issue tracker for free. That's not equitable and it's not sustainable. Business people understand that. I.T. people need to explain how this works, because when they do not explain it, and management continues to think it's all "free", the process doesn't work and it breaks down.

So now senior company management has issued the executive order to buy a pizza for a developer. The request now shifts from "please do this if you ever find time" to "I will give you this pizza if you do this". That motivation will get a lot more response than a request with no quid pro quo.

Some changes are worth coffee. Others are worth DisneyLand. Others are somewhere in the middle and may only cost a pizza. The point is Equity. The point is Respect for someone else's time. The point is that a developer's time is worth as much as yours when you're using their software to make your life easier.

Developers aren't really concerned about those who only take and do not give back. They don't care about the people who leave with indignation because their demands for free work are not processed. Contribute to documentation. Spend a week copy/pasting forum links into tracker items, and copy pasting tracker links into this forum. Help someone else to use the software. Gather funds for a specific change. Put a note in your forum sig that you're on a campaign to get funding for three pizzas in exchange for pretty emails. Do something to pay-forward or pay-back, and contribute in the spirit of FOSS. Those who do not take that step to even ask what they can do to help must be content with the equally value-less response that they receive on some requests.

And I'm not saying FOSS is a pay-to-play system. Developers and others who contribute to FOSS do it for their own reasons, whether to improve software for their own use, or for joy or profit or as a profile of their skills. Everyone does this for a different reason and to a different degree. I'm just saying that when a request is popular and there is High demand with No equity, there is a significant imbalance that becomes discouraging to those who have to measure how they spend their time. Respect that. Think about ways to balance it out. Talk about it in these forums.

And after all of that, sure, someone might just publish a cool solution to this specific problem entirely for free and for the pure joy of doing so. :)

If that does not happen, here is my suggestion #1 : You now need 4 pizzas! One for @vboctor, one for @dregad, one for @atrol, and one for whomever actually writes the code. Make the offer. See what happens. I doubt these guys will be bought with a pizza, but seriously, just do something that's more motivating than nothing.

Or better, suggestion #2 : Find someone near you who knows PHP, a colleague, your I.T. department, a student, grandma... and motivate Them with whatever is fair to the two of you to make and submit a new email module.

When you find something that works, repeat it for all projects and requests.

HTH
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Email output could be much prettier

Post by mushu »

Thank you for the lengthy and thoughtful response. It is appreciated.
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

Just for fun, I have investigated , how it could work for the body of the email message/
Within core/email_api.php i have adjusted function "email_bug_info_to_one_user" to allow to build the body.
This is triggered by a setting in config/config_inc.php called "$g_use_mailtemplate".
In addition one defines the template to be used in the same file by giving the absolute path of the template, variable called "$g_mailtemplate")
For now I have stored the template in core/template but this could be anywhere.
This all works fine, i do get a mail with my simple lay-out. Now we should have a nice lay-out of the email.
This is not really my thing so if someone comes up with a design, we can try to get it in
The template I now used, looked like

Code: Select all

{{ top_line }}
====================================
Project = {{ project }}
Reporter = {{ reporter }}
Issue-id = {{ bug_id }}	Summary = {{ summary }}
Description = {{ description }}
Due-Date = {{ due_date }}
As you can see, still very rudimentary, but a nice starting point.
So who wants to step in to give it the finishing touch?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

By the way, the template can contain of course HTML :wink:
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

Sample of the mail:
maillayout2.0.PNG
maillayout2.0.PNG (107.23 KiB) Viewed 366686 times
Still need to add some stuff like notes/attachments/history but that may not be a requirement since available online :mrgreen:
Reporter normally also has a value :wink:
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Email output could be much prettier

Post by mushu »

OMG what a difference!! I'd toss a <pre> in the steps to reproduce and additional information sections, but otherwise it's so much better than default. Great job, and so fast too...impressed! Now if we could get this built into the codebase so it won't go away after every update, that would be wonderful.

EDIT: what does it look like when the reporter adds a note and there are monitors on the project?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

something like this then:
mail-layout2.0.PNG
mail-layout2.0.PNG (47.6 KiB) Viewed 366682 times
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Email output could be much prettier

Post by mushu »

Add a note and see what it looks like please. The note text should also be <pre> but then that means hard line break lengths which are difficult to assume in an email unless you're using a <table> <td> cell which will auto-wrap. It looks SO GOOD!

EDIT: just saw you still needed to add a few things like Notes, sorry! I was too excited (lol). Our people are rather spoiled since we believe that things need to be the easiest and automatic they can be for our customers. So if they have to click a link to go read the Notes that were just updated on a project they may or may not do that. The current MantisBT includes the Notes in it's email when any are added or there is an update of some sort, so we would ultimately need to format those emails the same. Is this a one-off to the code you are doing, or is there a chance it can get included in the next release?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

The intention is that there is one script handling the formatting using as much as possible standard Mantisbt scripting.
So I do want to include all fields ( also notes/history/relationships) one way or another where possible.
The basic template will contain all the data i have gathered.
The idea is that you can copy the basic template and adjust to your liking.
Finally it is up to the developers to review the code and to decide to implement or not.
If not, it remains a development which need to be put in place after each update :(
So far it concerns:
2 additions config_inc.php
2 changes in email_api.php
1 new script: template_api.php
1 template : mail_template.html
You can have the code once you are ready to play with it :mrgreen:
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

@mushu , any idea how to solve this mis alignment of a table in a table?
mail-layout-issue.PNG
mail-layout-issue.PNG (26.16 KiB) Viewed 366634 times
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Email output could be much prettier

Post by mushu »

Need to see the HTML/CSS you're using for the container table and the inner table to tell.
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

well i use this for the container table:

Code: Select all

<html>
<style>
body {
    background-color: #93B874;
}
h1 {
    background-color: #00b33c;
}
p {
    background-color: #FFFFFF);
}
table, th, td {  
	border: 1px solid black;}
</style>
<h2 style="color:red; background:black;">
{{ top_line }}
</h2>
<br>
<table>
<tr><td><b>Issue-id </b> </td><td>{{ bug_id }} <a href={{ url }}> View all details inside the Issue Tracker</a></td></tr>
<tr><td><b>Reporter </b></td><td> {{ reporter }}</td></tr>
<tr><td><b>Project</b></td><td> {{ project }}</td></tr>
<tr><td><b>Category </b></td><td> {{ category }}</td></tr>
<tr><td><b>Summary</b></td><td> {{ summary }}</td></tr>
<tr><td><b>Description</B</td><td> {{ description }} </td></tr>
<tr><td><b>Steps to reproduce </b></td><td>{{ steps }}</td></tr>
<tr><td><b>Additional Information</b></td><td> {{ info }} </td></tr>
<tr><td><b>Due-Date</b></td><td> {{ due_date }}</td></tr>
<tr><td><b>Notes</b></td><td valign="top" style="float: left;"> {{ notedata }} </td></tr>
<tr><td><b>History</b></td><td style="float: left;">{{ hisdata }}</td></tr>
<tr><td><b>Referer</b></td><td> {{ reference }}</td></tr>
<tr><td><b>Available data</b></td><td> {{ mail_data }}</td></tr>

</html>
and this for the inner table:

Code: Select all

		$hisdata = "<table border=15 bordercolor = yellow><tr><b><td>Date</td><td>Username</td><td>Field</td><td>Change</td></b></tr><br>";
		foreach( $history as $t_his ) {
			$hisdata .= '<tr><td>'.$t_his['date'].'</td><td>'.$t_his['username'].'</td><td>'.$t_his['field'].'</td><td>'.$t_his['old_value']. '=> '.$t_his['new_value'].'</td></tr><br>';
		}
		$hisdata .='</table>';

So what is your vie?
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Email output could be much prettier

Post by mushu »

Seems to work fine for me, here is the code I'm using for testing followed by the output I get:

Code: Select all

<!doctype html>

<html>
<style>
body {
    background-color: #93B874;
}
h1 {
    background-color: #00b33c;
}
p {
    background-color: #FFFFFF);
}
table, th, td {  
	border: 1px solid black;}
</style>

<body>
<h2 style="color:red; background:black;">
{{ top_line }}
</h2>
<br>
<table>
<tr><td><b>Issue-id </b> </td><td>{{ bug_id }} <a href={{ url }}> View all details inside the Issue Tracker</a></td></tr>
<tr><td><b>Reporter </b></td><td> {{ reporter }}</td></tr>
<tr><td><b>Project</b></td><td> {{ project }}</td></tr>
<tr><td><b>Category </b></td><td> {{ category }}</td></tr>
<tr><td><b>Summary</b></td><td> {{ summary }}</td></tr>
<tr><td><b>Description</B</td><td> {{ description }} </td></tr>
<tr><td><b>Steps to reproduce </b></td><td>{{ steps }}</td></tr>
<tr><td><b>Additional Information</b></td><td> {{ info }} </td></tr>
<tr><td><b>Due-Date</b></td><td> {{ due_date }}</td></tr>
<tr><td><b>Notes</b></td><td valign="top" style="float: left;"> {{ notedata }}

<table border='15' bordercolor = 'yellow'>
<tr><b><td>Date</td><td>Username</td><td>Field</td><td>Change</td></b></tr><br>
<tr><td>'.$t_his['date'].'</td><td>'.$t_his['username'].'</td><td>'.$t_his['field'].'</td><td>'.$t_his['old_value']. '=> '.$t_his['new_value'].'</td></tr><br>
<tr><td>'.$t_his['date'].'</td><td>'.$t_his['username'].'</td><td>'.$t_his['field'].'</td><td>'.$t_his['old_value']. '=> '.$t_his['new_value'].'</td></tr><br>
<tr><td>'.$t_his['date'].'</td><td>'.$t_his['username'].'</td><td>'.$t_his['field'].'</td><td>'.$t_his['old_value']. '=> '.$t_his['new_value'].'</td></tr><br>
</table>

 </td></tr>
<tr><td><b>History</b></td><td style="float: left;">{{ hisdata }}</td></tr>
<tr><td><b>Referer</b></td><td> {{ reference }}</td></tr>
<tr><td><b>Available data</b></td><td> {{ mail_data }}</td></tr>

</table>
</body>
</html>
I put the table inside the Notes td cell and the table goes full width. This is a simple .htm file under IIS.
ss1.PNG
ss1.PNG (62.47 KiB) Viewed 366631 times
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Email output could be much prettier

Post by cas »

I will test in other browser, my test was done with Vivaldi 8O
Post Reply