Issues with renderLayout() and the MailService plugin

Hi group,

I’m trying to setup a mail service for our project and I thought I might be able to do this as part of my handler:-

...... rc.objMail.addMailPart(charset='utf-8',type='text/plain',body=renderLayout('Layout.Email.TextOnly','confirm/email.confirmation.textOnly')); rc.objMail.addMailPart(charset='utf-8',type='text/html',body=renderLayout('Layout.Email.HTML','confirm/email.confirmation.HTML')); .....

What seems to be happening though is the mailservice plugin is emailing out the handler’s “success” view and appending those declared in the renderLayout on to the end. So opening the email I’m getting what they should see in the browser.

Maybe I’m misunderstanding how renderLayout works but is there anyway I can say “I want this view, with this layout and give it to the mail object”?



Can you please share more of your code? I don’t see any issues on the lines you have posted.

Aaron Greenlee

Hi Aaron,

Changed things around a fair bit in the past 30 minutes so I’ve now got this …

rc.displayProp = {
// WARNING - It has to be kept in this running order for Gmail to display the HTML
html = {
name = ‘confirm/email.confirmation.HTML’,
noLayout = false,
layout = ‘Layout.Email.HTML’
plain = {
name = ‘confirm/email.confirmation.textOnly’,
noLayout = true,
layout = ‘’

// Request a new mail object and customise for this user
rc.objMailer = getMyPlugin(‘MailService’);
rc.objMail = rc.objMailer.newMail().config(
from = getSetting(‘email’).enrolment,
failTo = getSetting(‘email’).webTeam,
subject = getResource(‘email.confirmation.subject’)

// Add the email body ( text-only and HTML branded )
for(rc.key in rc.displayProp){

// rc.results = rc.objMailer.send(rc.objMail);

// Reset the layout and view

I do this:

Mail.setBody( getPlugin( "Renderer" ).renderLayout(
layout="Layout.Email", view="tags/email/enquiry" ) );

- John