Hello all, I’ve been working with ColdFusion for a while now but am new to ColdBox and MVC in general. I’ve set up a test site and am having problems figuring out how to send emails using the cbmailservices plugin. I have what I hope are some basic newbie questions. I keep getting an error:
Here is my model, emailService.cfc. I am using the sample code from ForgeBox: ColdBox Mail Services.
`
component accessors=“true”{
// Properties
property name=‘mailService’ inject=‘mailservice@cbmailservices’;
property name=‘renderer’ inject=‘provider:coldbox;renderer’;
/**
- Constructor
*/
emailService function init(){
return this;
}
function contactUs(event,rc,prc) {
// build mail and send
var oMail = getInstance( “mailService@cbmailservices” )
.newMail( to="myself@myemail.com",
from="myself@myemail.com
",
subject=“Mail Services Rock”,
bodyTokens={ user=“Luis”, product=“ColdBox”, link=event.buildLink( ‘home’ )} );
// Set a Body
oMail.setBody("
Dear @user@,
Thank you for downloading @product@, have a great day!
");//send it
var results = mailService.send( oMail );
}
}
`
Here are my settings from conbox.config:
mailsettings = { // The default token Marker Symbol tokenMarker = "@", // protocol protocol = { class = "cbmailservices.models.protocols.CFMailProtocol", properties = {} } };
Do I need anything else in the config file? Won’t coldbox pick up username and password from the Lucee settings? Sending emails with works fine btw.
I sure would appreciate any tips or suggestions! Thanks in advance!