Custom email template for EmailFactory.sendParameterizedEmail

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
Hi all,
i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

my code is the follow:

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);


From EmailFactory source code, i guess the problem is on:

 
if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)


/email/news.vtl code is

MY EMAIL TEMPLATE $text WORKS!!!




Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e47368c415af4393b462e4ac4dd93c58%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
Thank you Nathan.

I'll try and let you know!

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

Djacomo


Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="qu8jr0yTBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="qu8jr0yTBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="qu8jr0yTBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="qu8jr0yTBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/89b0391b26574707a003f0322d92cca5%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
this code: 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );


get this error:

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

???


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ftgoKuqUBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ftgoKuqUBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ftgoKuqUBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ftgoKuqUBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter
In reply to this post by Nathan Keiter

Included on that template page is a Simple Widget that does a #dotParse( ‘/some/path/someFile.vtl’ ) of a velocity file.  I believe this keeps things better organized.  Also as a plus you can easily upload changes via WebDAV if you put your velocity in as files in the virtual file system tree instead of obfuscating them as content objects - which forces edits to be done in the back-end UI and makes things harder to find in my opinion.

 

Also of note, the page uses a “blank template”, meaning the template source is just $body, nothing else.

 

You can see in the velocity widget source how I am accessing the objects I added to context, “host” and “user”.

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 9:48 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/89b0391b26574707a003f0322d92cca5%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/60ca1f5812914f499784f74f95f7e336%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter
In reply to this post by Djacomo

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1423c627cb5c4988b41bf2ad2507cd6d%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
My projcet structure:

1) /application/themes/email-template/template.vtl


##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT



2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

In /email/template.vll

HELLO WORKD


Where is my mistakes?

Thx



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@...
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CeWnq1uWBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

Did you add $dotThemeLayout  to the context in Java?  If not that object will be null.  I’m not sure where to fetch that from, perhaps a dotCMS API call in Java?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:34 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

My projcet structure:

 

1) /application/themes/email-template/template.vtl



##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT

 

2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

 

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

 

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

 

In /email/template.vll

 

HELLO WORKD

 

 

Where is my mistakes?

 

Thx

 



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: <a href="javascript:" target="_blank">dot...@...
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

Also, $render may need to be added to context. If you don’t explicitly add an object to context, it won’t be there.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:39 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Did you add $dotThemeLayout  to the context in Java?  If not that object will be null.  I’m not sure where to fetch that from, perhaps a dotCMS API call in Java?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:34 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

My projcet structure:

 

1) /application/themes/email-template/template.vtl



##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT

 

2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

 

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

 

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

 

In /email/template.vll

 

HELLO WORKD

 

 

Where is my mistakes?

 

Thx

 



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: <a href="javascript:" target="_blank">dot...@...
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/7eee93f672d341f9aac62b40a5f45689%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
i can remove dotThemeLayout ???

and $render too?

That theme is my common theme without css and other things...

i suppose it's a wrong theme.

Djacomo

Il giorno mercoledì 26 luglio 2017 16:40:40 UTC+2, Nathan Keiter ha scritto:

Also, $render may need to be added to context. If you don’t explicitly add an object to context, it won’t be there.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:39 AM
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@...
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Did you add $dotThemeLayout  to the context in Java?  If not that object will be null.  I’m not sure where to fetch that from, perhaps a dotCMS API call in Java?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [<a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mailto...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:34 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

My projcet structure:

 

1) /application/themes/email-template/template.vtl



##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT

 

2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

 

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

 

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

 

In /email/template.vll

 

HELLO WORKD

 

 

Where is my mistakes?

 

Thx

 



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="y1NuN8eXBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/82b56af0-25e6-4f6c-9925-3d18c5435cc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Custom email template for EmailFactory.sendParameterizedEmail

Nathan Keiter

You’ll need to build a basic template from scratch.  Don’t use template designer.

 

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:47 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

i can remove dotThemeLayout ???

 

and $render too?

 

That theme is my common theme without css and other things...

 

i suppose it's a wrong theme.

 

Djacomo

Il giorno mercoledì 26 luglio 2017 16:40:40 UTC+2, Nathan Keiter ha scritto:

Also, $render may need to be added to context. If you don’t explicitly add an object to context, it won’t be there.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [mailto:<a href="javascript:" target="_blank">dot...@...] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:39 AM
To: <a href="javascript:" target="_blank">dot...@...
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Did you add $dotThemeLayout  to the context in Java?  If not that object will be null.  I’m not sure where to fetch that from, perhaps a dotCMS API call in Java?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank">dot...@... [<a href="javascript:" target="_blank">mailto...@...] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:34 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

My projcet structure:

 

1) /application/themes/email-template/template.vtl



##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT

 

2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

 

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

 

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

 

In /email/template.vll

 

HELLO WORKD

 

 

Where is my mistakes?

 

Thx

 



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/5a08009ff4874a289d745c17fd382fdd%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/c600d21d-9ab5-4742-b3e2-21bf94206afe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">dotcms+un...@....
To post to this group, send email to <a href="javascript:" target="_blank">dot...@....
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/192937c803824dc3828e6912a7da2ee3%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/82b56af0-25e6-4f6c-9925-3d18c5435cc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/a3c79fde2e42499a9892f109fb3209d9%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Custom email template for EmailFactory.sendParameterizedEmail

Djacomo
it's works...and with a my custom theme!!!

In the next days i'll paste the snippets!!!

Thank you very much Nathan!!!

Djacomo

Il giorno mercoledì 26 luglio 2017 16:53:38 UTC+2, Nathan Keiter ha scritto:

You’ll need to build a basic template from scratch.  Don’t use template designer.

 

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="wUq5h3yYBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="wUq5h3yYBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:47 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

i can remove dotThemeLayout ???

 

and $render too?

 

That theme is my common theme without css and other things...

 

i suppose it's a wrong theme.

 

Djacomo

Il giorno mercoledì 26 luglio 2017 16:40:40 UTC+2, Nathan Keiter ha scritto:

Also, $render may need to be added to context. If you don’t explicitly add an object to context, it won’t be there.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:39 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Did you add $dotThemeLayout  to the context in Java?  If not that object will be null.  I’m not sure where to fetch that from, perhaps a dotCMS API call in Java?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [[hidden email]] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:34 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

My projcet structure:

 

1) /application/themes/email-template/template.vtl



##IMPORTANT
#parse ("preprocess.vl")
##IMPORTANT


<!DOCTYPE html>
<html lang="en">
<!--<![endif]-->


<head>


</head>


<body>
<h1> EMAIL THEME </
h1>
<div>
   
#set ($mainColumn = $dotThemeLayout.body)
   
#if ($mainColumn.rows)
       
#set($count = 0)
       
#foreach($row in $mainColumn.rows)
           
#foreach($column in $row.columns)
               
<div class="col-sm-12">
                    $render
.eval($column.draw())
               
</div>
            #end
        #end
    #end
</
div>


</body>
</
html>


##IMPORTANT
#parse ("postprocess.vl")
##IMPORTANT

 

2) Created a "Emai Template" with this "email theme" theme and a "Large column - 1" container

 

3) Create a HTML PAGE /email/email.html and assigner the "Email Template"

 

4) Added "VTL Include" /email/template.vtl to "/email/email.html" 

 

In /email/template.vll

 

HELLO WORKD

 

 

Where is my mistakes?

 

Thx

 



Il giorno mercoledì 26 luglio 2017 16:14:38 UTC+2, Nathan Keiter ha scritto:

As a general rule, work your way up from simple to complex until you encounter an error.  Then the cause will become apparent.  So maybe start with a plain text template with no velocity on it?  Also I’m not sure what if any permissions requirements there are.  I don’t think there are any, but I’m not sure.  The template page should at least be published.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Wednesday, July 26, 2017 10:10 AM
To: [hidden email]
Subject: RE: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Yeah, I forgot to mention language id is only required for dotCMS 3.x +

 

As for your error, can you provide more information?

 

Often a merge error is the result of a velocity code error.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 10:04 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

this code: 

 

            VelocityEngine velocityEngine = new VelocityEngine();
            velocityEngine
.init();


           
String inode = identifierAPI.find(host, "/email/email.html").getInode();


           
String languageId = "_" + APILocator.getLanguageAPI().getDefaultLanguage().getId();


            log
.info("Languageid " + languageId);


           
String pageExtension = Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENTION", "dotpage");


           
String liveUrl = "live/" + inode + "." + pageExtension; // REMOVED languageid for "NumberFormatException"


            log
.info("Liveurl " +liveUrl);


           
Template template = UtilMethods.getVelocityTemplate(liveUrl);


            log
.info("Template " + template.getName());


           
Context velocityContext = VelocityUtil.getBasicContext();
            log
.info("Contesto " +velocityContext);
//            velocityContext.put("host", host);
//            velocityContext.put("user", user);


           
StringWriter stringWriter = new StringWriter();
           
template.merge(velocityContext, stringWriter);


           
String htmlBody = stringWriter.toString();


            log
.trace("HTML BODY " + htmlBody );

 

 

get this error:

 

HTML BODY $velutil.mergeTemplate('live/1a0d6e9c-b7a3-4593-8211-53b39660324f.host')    $velutil.mergeTemplate("$dotTheme.templatePath")

 

???

 


Il giorno mercoledì 26 luglio 2017 15:48:11 UTC+2, Nathan Keiter ha scritto:

It is a page object.  Of course velocity content of some sort is included on the page either directly as content or via a widget.

 

Any variables you want to have accessible to that page must be added to the velocity context manually via Java. You add them in key/object pairs, where the key becomes the velocity variable name with a $ in front.  They are then accessible to velocity for the merge. During the merge the variables are replaced with the objects and any velocity scripting is run before returning the “rendered page” result string.

 

So velocityContext.put( “someJavaObject”, myJavaObject );

 

Is then available in velocity as $someJavaObject etc.

 

#if ( $someJavaObject.getSomeValue() == true )##

            <b>$someJavaObject.getSomePropertyValue()</b>

#end##

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 9:35 AM
To: dotCMS User Group
Subject: Re: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Thank you Nathan.

 

I'll try and let you know!

 

For curiosity, what type of TEMPLATE did you use? ACCOUNT_ACTIVATION_EMAIL_PATH, is a path to a VTL file?

 

Djacomo



Il giorno mercoledì 26 luglio 2017 15:18:35 UTC+2, Nathan Keiter ha scritto:

Djacomo,

 

I think I remember that not working for me as well.  The odd thing is my own code is basically doing the same thing as the dotCMS code, but mine works.  Since you are already coding Java.  Write your own email method to utilize the template:

 

 

If you don’t have a request context available, you can get a basic context:

 

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: [hidden email] [mailto:dot...@googlegroups.com] On Behalf Of Djacomo
Sent: Wednesday, July 26, 2017 4:35 AM
To: dotCMS User Group
Subject: [dotcms] Custom email template for EmailFactory.sendParameterizedEmail

 

Hi all,

i'm trying to create a custom template for an email to send via EmailFactory.sendParameterizedEmail() API .

 

The only way it works is add a row in dotmarketing-config.properties near to "ACTIVATION_LINK_EMAIL_TEMPLATE=static/user_account/activation_link_email.html ", like "MY_TEMPLATE=static/user_account/news.html" but is very hard to handle change request (i must stop and restart the tomcat).

 

Reading documentation, it seems that there are a way to indicate a VTL/HTML page, like /email/news.vtl , but i get an send email error, ""Unable to send the email".

 

my code is the follow:

 

Host host = hostWebAPI.getCurrentHost(request);

User user = APILocator.getUserAPI().getSystemUser();

...
HashMap<String, Object> parameters = new HashMap<>();

...
parameters
.put("text", "text to insert");
parameters
.put("emailTemplate", "/email/news.vtl");
...
EmailFactory.sendParameterizedEmail(parameters, null, host, user);

 

From EmailFactory source code, i guess the problem is on:

 

 

if(UtilMethods.isSet(templatePath)) {
            idInode
= APILocator.getIdentifierAPI().find(host, templatePath).getInode();
           
Template t = null;


           
try {
               
if(InodeUtils.isSet(idInode)) {
                    t
= UtilMethods.getVelocityTemplate("live/" + idInode + "." + Config.getStringProperty("VELOCITY_HTMLPAGE_EXTENSION"));
               
} else {
                    t
= UtilMethods.getVelocityTemplate(templatePath);
               
}
           
} catch (Exception var19) {
               
;
           
}

 

Using same code idInode = APILocator.getIdentifierAPI().find(host, templatePath).getInode();

 

"t" value is "live/70909....09123.dotpage    (70909....09123 is the /email/news.vtl's inode)

 

 

/email/news.vtl code is

 

MY EMAIL TEMPLATE $text WORKS!!!

 

 

 

 

Anyone can help me!!!  There is another way to send a custom email?

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/a2d29b2b-1e25-4106-8cba-254a549b1fd5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/b041d2c6-30d7-4b73-94c4-5a24ee6748e5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> https://groups.google.com/d/optout.

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/95ce03d7-79b8-4aad-8941-1a57e5e15c07%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollo