Emails with unexpanded templates
Posted: Thu Nov 19, 2015 3:51 pm
I've installed LogicalDOC Community Edition 7.3 on an Ubuntu 12.04 LTS virtual machine (Vagrant), for testing. I've a problem with outgoing emails.
My VM has postfix installed but no actual connectivity, to avoid accidents, so I'm looking at emails that are stuck in the outgoing queue in the VM, and this is what I see:
You can see how the template is not expanded:
I spent maybe an hour trying to figure this out, and I'm about to give up. As far as I can tell, the source code for email formatting (community/logicaldoc/logicaldoc-core/src/main/java/com/logicaldoc/core/communication/MessageTemplate.java) does this:
i.e. if any error happens during Velocity.evaluate(), that error is silently swallowed and not recorded in any log file.
Any advice for debugging this? Anything simpler than editing out that try/catch and learning how to build the entire product so I can see what the underlying error is?
My VM has postfix installed but no actual connectivity, to avoid accidents, so I'm looking at emails that are stuck in the outgoing queue in the VM, and this is what I see:
Code: Select all
*** MESSAGE CONTENTS /var/spool/postfix/deferred/B/B030842B04 ***
Received: from vagrant-ubuntu-precise-64 (localhost [127.0.0.1])
by vagrant-ubuntu-precise-64 (Postfix) with ESMTP id B030842B04
for <admin@admin.net>; Thu, 19 Nov 2015 11:09:25 +0000 (UTC)
From: logicaldoc@acme.com
To: admin@admin.net
Message-ID: <839557298.3.1447931365722.JavaMail.logicaldoc@vagrant-ubuntu-precise-64>
Subject: $product - $I18N.get('emailnotifyaccountobject')
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2_636999199.1447931365689"
Date: Thu, 19 Nov 2015 11:09:25 +0000 (UTC)
------=_Part_2_636999199.1447931365689
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
$I18N.format('emailnotifyaccount', $user.fullName) <br/> $I18N.get('username'): <b>$user.userName</b> <br/> $I18N.get('password'): <b>$password</b> <br/> $I18N.get('clickhere'): <a href="$url">$url</a>
------=_Part_2_636999199.1447931365689--
*** HEADER EXTRACTED /var/spool/postfix/deferred/B/B030842B04 ***
*** MESSAGE FILE END /var/spool/postfix/deferred/B/B030842B04 ***
Code: Select all
Subject: $product - $I18N.get('emailnotifyaccountobject')
Code: Select all
$I18N.format('emailnotifyaccount', $user.fullName) <br/> $I18N.get('username'): <b>$user.userName</b> <br/> $I18N.get('password'): <b>$password</b> <br/> $I18N.get('clickhere'): <a href="$url">$url</a>
Code: Select all
StringWriter writer = new StringWriter();
try {
Velocity.evaluate(context, writer, getName(), text.replace("\n", "${nl}"));
return writer.toString();
} catch (Exception e) {
return text;
}
Any advice for debugging this? Anything simpler than editing out that try/catch and learning how to build the entire product so I can see what the underlying error is?