newMail()
) or via the injected mail service's newMail()
method. The arguments you pass into this method will be used to seed the payload with all the arguments passed to the cfmail
tag or the chosen protocol properties. You can also pass an optional mailer
argument which will override the default
protocol to one of your liking.newMail()
helper is useful so you can send mail from your handlers and interceptors.[email protected]
to inject the service in any model object to send mail from your models.newMail()
calls will be a Mail
payload object of type cbmailservices.models.Mail
. You can find all the full API Docs here:newMail()
or configure()
method is used to initiate and configure a mail payload. Any argument you pass into these methods will be used to seed the mail config
property which is used by all protocols to send email out. Example, the cfmail
protocol will read all those properties and pass them as an attribute collection to the cfmail
tag.send()
method to initiate a call to the mail protocols to deliver your mail using your payload. You can then tap into the results of the mailing via the mail callbacks or the mail helper methods. Please also note that the sending operation announces two interceptions points (preMailSend, postMailSend
) that you can use to influence the mail payload or listen to mail results.onSuccess( callback )
onError( callback )
callback
argument is a function/closure/lambda that receives two arguments:result
: The result structure with at least two keys: { error :boolean, messages: array }
mail
: The mail payload itself.mailer
argument to the newMail()
calls or by calling the setMailer( mailer )
method.tokenMarker
setting which defaults to @
. Here is the token pattern:bodyTokens
argument to the newMail() or configure()
methods, or you can use the setBodyTokens()
method.setView()
method. Here is the method signature:args
structure as well. You can also use the bodyTokens
in your views. Then you can use it in your mail sending goodness:addAttachments()
. files
argument can be a list of file locations or an array of file locations to send.cfmailparam
) to a payload so you can attach headers or files to the message by using the addMailParam()
method. Please see the https://cfdocs.org/cfmailparam cfmail param docs for more information.cfmailpart
feature of cfmail
(https://cfdocs.org/cfmailpart). This allows you to build multi-parted emails.setReadReceipt( email )
- Set the read receipt emailsetSendReceipt( email )
- Set the send receipt emailsetHtml( body )
- Set a multi-part body for htmlsetText( body )
- Set a multi-part body for textaddAttachments( files, remove=false)
- Easily add attachmentsgetMemento()
- Get the entire mail settings for the payloadhasErrors():boolean
- Verifies if there are any errors in the mailinggetResultMessages():array
- Get's the array of messages of the sending of the mailgetResults():struct
- Get the structure of the results of sending the mailMail
object has some additional methods to allow you to pass additional information so protocols can leverage them: