Return to Project-GC

Welcome to Project-GC Q&A. Ask questions and get answers from other Project-GC users.

If you get a good answer, click the checkbox on the left to select it as the best answer.

Upvote answers or questions that have helped you.

If you don't get clear answers, edit your question to make it clearer.

Usability of emails with notification from Q&A

+2 votes
261 views
Emails notifying about changes in Q&A are great, but would it be possible to make the links in HTML clickable or/and to make it more structured? Non-html version is fine, but HTML version is less useful. It adds only subject and large image, which is blocked by most of clients.

Proposing as feature requrest, since I know that this is third party software and not first priority. I can also post such a proposal to upstream if they woul accept such a change.
asked Mar 1, 2015 in Feature requests by Jakuje (Moderator) (93,530 points)

1 Answer

0 votes
We haven't prioritied to look into it really, but I know the mails have some issues. If I remember correct, the mails from the QA-system are from an addon and not from the mainline source code either actually.

Most of the time I find all links clickable though. But that might be gmail magic since I am using their web interface to read them.
answered Mar 1, 2015 by magma1447 (Admin) (211,560 points)
Thank you for a comment. If you prioritize this problem somehow, I don't think this will not be hard one :) If I could help somehow, please let me know.
Yes. It is probably gmail magic. It is also clickable on my phone as I see now, but not in Thunderbird, for example. And it looks like there are more people concerned about this issue.
Hey. I don't want to nudge you, but I see there is nothing new about this in recent mails. If you don't have time to wiggle with it, let me know about what plugin are you using and I will have a look into it.
As you probably know, we are using http://www.question2answer.org/
We do have a few patches, but they should not be related to this. One of our patches is the "authentication", ie, use the cookie from Project-GC (single signon).

We are currently running version 1.6.3, I see that 1.7.2 is the latest. I have not read the changelog very careful. It's available at http://www.question2answer.org/versions.php and I can not see anything email related.

We then use the https://github.com/ruuttt/q2a-email-formating addon to make the emails HTML. But it seems like all the addon does, is what you says. Adds soms header.

The correct solution for what you want, is probably to ask for it in the projects QA forum though, which has been done at least once:
http://www.question2answer.org/qa/48453/is-it-too-late-for-a-html-email-template-solution-for-q2a?show=48453#q48453
(I searched the forum for HTML)

The other alternative could be to fork/patch the email-formatting addon to regexp links and make them hrefs. Safer to fix the QA-source though.


As a side note, I sometimes get broken links from the QA-site. Like this:
http://proj ect-gc.com/...
I didn't see any fix for that either. Though I am not sure where the error comes from.
Thank you for extensive write-up. I finally find some quite free eventing to have a look into that.

Translations contain the link as "^url" in qa-include/lang/qa-lang-emails.php

Notifications are send from:
 * qa-include/plugins/qa-event-notify.php
   * the translations and actual URLs are gathered together, but yet not substituted
   * qa_q_path() is used to get the URL, there is qa_q_path_html(), which would be cleaner solution.
 * qa-include/app/emails.php
   * qa_send_notification()
     * substitutes the ^url for the actual link
   * qa_send_email()
     * "redefined" by plugin.
     * gets already substituted in plaintext format
     * uses several methods to convert to HTML:  qa_html()

So what is the actual problem?
 * We have non-html message which is just put into HTML "frame" and send.
 * This is not the problem of the core, but the problem of the plugin. Though having this feature in the core would be nice, but there ain't nobody having time for doing this from scratch into existing project.

So what to do?
 * as you propose use some regex to rewrite the URL to valid HTML link. This seems ugly, because it might break also other stuff
 * "overwrite" also qa_send_notification() and inject the html in the links makes more sense.
My commit. I will propose it as a pull request later, if you will be satisfied with such solution:
https://github.com/Jakuje/q2a-email-formating/commit/29848d6a4f41ea462ab763bdc0beefe405ecea09


To the broken links (I saw few of them also recently), I believe it is caused by the weird encoding:
    * content-transfer-encoding: quoted-printable

It is fine for normal text, but it breaks html and long lines. Have a look in the source code of the notification mails. It is real pain, especially with all that CSS.

Example from one of the broken mails:
p></p><p>http://p=0D
 roject-gc.com/qa/?qa=3D4002/usability-of-emails-with-notification-from-q%2=

It should be possible to instrument the PHP Mailer to use different encoding, I would be for classing base64 to make sure it is delivered as it is send, though it might be arguable. The idea:

diff --git a/qa-include/app/emails.php b/qa-include/app/emails.php
index da9ab33..955cc08 100644
--- a/qa-include/app/emails.php
+++ b/qa-include/app/emails.php
@@ -133,6 +133,7 @@
         $mailer->AddAddress($params['toemail'], $params['toname']);
         $mailer->Subject=$params['subject'];
         $mailer->Body=$params['body'];
+        $mailer->Encoding = 'base64';
 
         if ($params['html'])
             $mailer->IsHTML(true);
I am impressed. I will try to look at this and include your patch the coming days. While at it, we should upgrade the Q2A software to the latest version.

Please remind me if it's not done in a week or so. I know I won't have time tomorrow. Need to do Decembers bookkeeping. :(
Of course both changes were tested on dirty-set-up local instance with faked sendmail. It might be needed to escape some more user input, but I don't feel like doing that today.
Another possibility to the encoding might be to include two versions of email, one plaintext and the other base64 HTML as I remember it should be possible.

No problem. Glad to help and improve this project. Anyway, I will remember myself as I will receive some more emails in the old form :)
You are correct. One can send both a plain text and a html mail in one mail. In raw form I am unsure about the details though.

Q2A uses phpmailer (if I recall correctly). I am don't know that one either. PGC uses Swiftmail which I am then a bit more used to. But I assume it's as easy regardless. And I don't know much about Swiftmailer either actually. PGC started to use it fairly recently, and we have no need for black magic.
Some followup.

Bookkeeping done for the month. After that I disabled the Q2A system for all users and started to upgrade the software, after some backups.

Took me a while to realize (and then remember) that Q2A had switched to mysqli, which of course affected my authentication code, which uses the database connections.

The theme was also patched a bit, it took me a while to make it work again. Much more work when one doesn't remember what one did the last time, and how the system works. When done I realized it was fairly simple. But still not as simple as making a diff of the old changes and applying it. Too much had changed and I had to manually make similar changes again.

Anyway. Now the system is running the latest version. I will give it a few days before I add a patch into the mix. If there are issues, I prefer to know where the issues are coming from.
Thanks! So far looks working. The last mail looked much better then the previous ones. The quoted printable do not look so awful now: =0D got away (additional CR  in old version), but all that CSS and the format might need some improvements though.
Interesting. If I wasn't clear enough, I did not apply your patch yet, just updated the version.

Without analyzing I don't see any difference on the mails myself yet. However I noticed there is a non working Unsubscribe link. Not sure if it has worked before.
...