coldbox-modules / cbmailservices Goto Github PK
View Code? Open in Web Editor NEWA ColdBox module that allows you to send mail with different protocols and nice abstractions
A ColdBox module that allows you to send mail with different protocols and nice abstractions
If "defaults" are set in the configuration, they overwrite the values in the passed payload of the mailbean.
This should be the other way round or have I misunderstood something here?
In mailservice.newMail() in line 246
structAppend( arguments, variables.defaultSettings );
# should be
structAppend( arguments, variables.defaultSettings, false );
I discovered an issue when playing around with the cbmailservices if an email has a binary attachment and the email fails validation, it will throw an exception via LogBox because Logbox can't handle binary data.
JSON serialization failure: Unable to serialize binary data to JSON.
coldbox\system\logging\LogEvent.cfc:82
coldbox\system\logging\appenders\ConsoleAppender.cfc:50
coldbox\system\logging\Logger.cfc:399
coldbox\system\logging\Logger.cfc:301
modules\cbmailservices\models\MailService.cfc:272
I'm not sure if Logbox will ever be able to handle binary data, so it might be a good idea to strip anything binary from mailParams
as a precaution, just to be safe.
Here's how you can replicate the issue:
var email = mailService.newMail(
to = "", // intentionally blank
from = "[email protected]",
subject = "All Your Base Are Belong to Us",
type = "html",
body = "<p>Hello</p>
);
email.addMailParam(
file = "my-document.pdf",
content = toBinary( base64PdfFile ),
type = "application/pdf"
);
mailService.send( email );
An error is throw in the parseTokens method due to the recently added check for the mail type (line 380)
// Do not process tokens if using dynamic template (send-grid-protocol)
if ( arguments.mail.getType() == "template" ) return;
The property (Type) doesn't exist. Valid properties are leadId,mailParams,environment,mailParts,source,associationName,notes,customerId,agentId,subject,bodyTokens,to,additionalInfo,additionalJSONData,conversationMessageId,uniqueId,cc,from,fromName,body,bcc
…
The code should execute without error, bypassing this check as there is no 'type' property defined on the object.
…
…
…
Operating System: …
Package Version: 2.8.1
As currently coded the Mailgun protocol assumes a US region domain. If the domain is associated with the EU region it just returns "Forbidden", not even a JSON formatted string! As a result all call fails.
I've coded up a proposed solution that I'm currently using and will raise a pull request on this repo and one for the docs.
When I set a property for templateDynamicFields as a URL,
And put this in the HTML attribute href of <A href="">
tag.. The mail wil not be submitted. without any errors. <a href="@niceUrlProperty@">test</a>
My mail settings:
mailData = {
from: "[email protected]"
,to: "[email protected]"
,subject: "subject"
,mailHtmlContent: Renderer.renderView(view='/mails/passwordActivationMail')
,templateDynamicFields: {activationUrl: "http://testwebsite.com/urltoapage/.."}
};
var newMail = MailService.newMail();
//required
newMail.setFrom(mailData.from);
newMail.setTo(mailData.to);
newMail.setSubject(mailData.subject);
newMail.setFailTo(arguments.failTo);
//fill the dynamic fields
if(!structIsEmpty(mailData.templateDynamicFields)){
newMail.setBodyTokens(mailData.templateDynamicFields);
}
//set html
newMail.setHtml(mailData.mailHtmlContent);
//send the mail
var result = mailService.send( newMail );
`
And the mail template:
<!--- ************************************************************************************************************** --->
<!--- BUTTON --->
<!--- ************************************************************************************************************** --->
<table class="btn-primary" cellpadding="0" cellspacing="0" border="0" style="font-family: Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 100%; line-height: 1.6em; color: ##757575; width: auto !important; Margin: 0 0 10px; padding: 0;">
<tr style="font-family: Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 100%; line-height: 1.6em; margin: 0; padding: 0;">
<td style="font-family: Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 14px; line-height: 1.6em; border-radius: 3px; text-align: center; vertical-align: top; background: ##3b8fbb; margin: 0; padding: 0;" align="center" bgcolor="##3b8fbb" valign="top">
<a href="@activationUrl@" style="font-family: Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 100%; line-height: 2; color: ##ffffff; border-radius: 3px; display: inline-block; cursor: pointer; font-weight: bold; text-decoration: none; background: ##3b8fbb; margin: 0; padding: 0; border-color: ##3b8fbb; border-style: solid; border-width: 10px 20px;">click me!/a>
</td>
</tr>
</table>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.