models

Class MailService

lucee.Component
    extended by models.MailService

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ---- The ColdBox Mail Service is used to send emails in a fluent and human fashion.

Class Attributes:
  • threadsafe
  •  
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Luis Majano
  •  
    Property Summary
    type property default serializable required
    any asyncManager


    • access = public
    • returntype = any
    • inject = coldbox:asyncManager
    true false
    string defaultProtocol
          The default protocol used for sending mail.

    • access = public
    • returntype = any
    true false
    struct defaultSettings
          Mail Defaults that are used by all mailer protocols.

    • access = public
    • returntype = any
    true false
    any inteceptorService


    • access = public
    • returntype = any
    • inject = coldbox:interceptorService
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any mailQueue
          The concurrent mail queue used by our scheduler to send asynchronous queued mail tasks.

    • access = public
    • returntype = any
    true false
    struct mailers
          Collection of mailers used for mailings.

    • access = public
    • returntype = any
    true false
    any settings


    • access = public
    • returntype = any
    • inject = coldbox:moduleSettings:cbmailservices
    true false
    string tokenMarker
          The token marker used for token replacements, default is `@`.

    • access = public
    • returntype = any
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    string getAsyncManager()
    struct getDefaultMailer()
         Get the default mailer record.
    string getDefaultProtocol()
    any getDefaultSetting(any setting, [any defaultValue])
         Convenience method to get a mail default setting value.
    string getDefaultSettings()
    string getInteceptorService()
    string getLog()
    string getMailQueue()
    struct getMailer(any name)
         Get a mailer record by name.
    string getMailers()
    array getRegisteredMailers()
         Get an array of names of the registered mailers.
    string getSettings()
    string getTokenMarker()
    string getWirebox()
    Mail newMail()
         Get a new Mail payload object, just use config() on it to prepare it or pass in all the arguments via this method.
    any onDIComplete()
         Prepare the mail services for operation.
    any parseTokens(any mail)
         Parse the tokens and do body replacements.
    any processQueue()
         This method is called by our scheduling services or can be called manually to process the queue for.
    string queue(any mail)
         Queue the mail payload into our asynchronous work queue.
    MailService registerMailer(any name, any class, [struct properties='[runtime expression]'])
         Dynamically register a mailer protocol in this mail service.
    MailService registerMailers(struct mailers)
         Register a struct of mailers in this mail service according to our convention:.
    Mail send(Mail mail)
         Send an email payload and returns to you the payload.
    any sendAsync(any mail)
         Send an email payload asynchronously and return a ColdBox Future.
    any setAsyncManager(any asyncManager)
    any setDefaultProtocol(string defaultProtocol)
    MailService setDefaultSetting(any setting, [any value])
         Convenience method to set a default setting value.
    any setDefaultSettings(struct defaultSettings)
    any setInteceptorService(any inteceptorService)
    any setLog(any log)
    any setMailQueue(any mailQueue)
    any setMailers(struct mailers)
    any setSettings(any settings)
    any setTokenMarker(string tokenMarker)
    any setWirebox(any wirebox)
    private MailService storeMailDefaults([any server], [any username], [any password], [numeric port], [any from], [any to], [any body], [any bcc], [any cc], [any charset], [boolean debug='false'], [any failto], [any group], [boolean groupcasesensitive], [any mailerid], [numeric maxrows], [any mimeattach], [any priority], [any query], [any replyto], [boolean spoolenable], [numeric startrow], [any subject], [numeric timeout], [any type], [boolean useSSL], [boolean useTLS], [numeric wraptext])
         Store the mail defaults.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    asyncManager

    property any asyncManager

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:asyncManager
    serializable - true

    defaultProtocol

    property string defaultProtocol

    The default protocol used for sending mail. The default is called `default` :)

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    defaultSettings

    property struct defaultSettings

    Mail Defaults that are used by all mailer protocols

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    inteceptorService

    property any inteceptorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:interceptorService
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    mailQueue

    property any mailQueue

    The concurrent mail queue used by our scheduler to send asynchronous queued mail tasks

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    mailers

    property struct mailers

    Collection of mailers used for mailings

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    settings

    property any settings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:moduleSettings:cbmailservices
    serializable - true

    tokenMarker

    property string tokenMarker

    The token marker used for token replacements, default is `@`

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    getAsyncManager

    public string getAsyncManager()


    getDefaultMailer

    public struct getDefaultMailer()

    Get the default mailer record

    Returns:
    { class:"", properties : {}, transit : object }

    getDefaultProtocol

    public string getDefaultProtocol()


    getDefaultSetting

    public any getDefaultSetting(any setting, [any defaultValue])

    Convenience method to get a mail default setting value

    Parameters:
    setting - The setting key to get
    defaultValue - The default value to return if the setting key doesn't exist
    Throws:
    SettingNotFoundException - if the setting doesn't exist and no default value passed

    getDefaultSettings

    public string getDefaultSettings()


    getInteceptorService

    public string getInteceptorService()


    getLog

    public string getLog()


    getMailQueue

    public string getMailQueue()


    getMailer

    public struct getMailer(any name)

    Get a mailer record by name

    Parameters:
    name
    Returns:
    { class:"", properties : {}, transit : object }
    Throws:
    UnregisteredMailerException - When an invalid name is sent

    getMailers

    public string getMailers()


    getRegisteredMailers

    public array getRegisteredMailers()

    Get an array of names of the registered mailers


    getSettings

    public string getSettings()


    getTokenMarker

    public string getTokenMarker()


    getWirebox

    public string getWirebox()


    newMail

    public Mail newMail()

    Get a new Mail payload object, just use config() on it to prepare it or pass in all the arguments via this method All arguments passed to this method will be bound into the returning Mail object.


    onDIComplete

    public any onDIComplete()

    Prepare the mail services for operation


    parseTokens

    public any parseTokens(any mail)

    Parse the tokens and do body replacements.

    Parameters:
    mail - The mail payload to use for parsing and usage.

    processQueue

    public any processQueue()

    This method is called by our scheduling services or can be called manually to process the queue for mail sending


    queue

    public string queue(any mail)

    Queue the mail payload into our asynchronous work queue

    Parameters:
    mail - The mail payload to send.
    Returns:
    A unique identifier for the task that was registered for you.

    registerMailer

    public MailService registerMailer(any name, any class, [struct properties='[runtime expression]'])

    Dynamically register a mailer protocol in this mail service

    Parameters:
    name - The unique name of the protocol
    class - The protocol alias or wirebox id
    properties - The properties to instantiate the transit protocol with
    Returns:
    true

    registerMailers

    public MailService registerMailers(struct mailers)

    Register a struct of mailers in this mail service according to our convention:

    { class: "", properties : "" }
    

    Parameters:
    mailers - The structure of mailers to register
    Throws:
    InvalidDefaultProtocol - If the default protocol was not registered in the mailers structure

    send

    public Mail send(Mail mail)

    Send an email payload and returns to you the payload

    Parameters:
    mail - The mail payload to send.
    Returns:
    Mail payload

    sendAsync

    public any sendAsync(any mail)

    Send an email payload asynchronously and return a ColdBox Future

    Parameters:
    mail - The mail payload to send.
    Returns:
    ColdBox Future object: coldbox.system.async.tasks.Future

    setAsyncManager

    public any setAsyncManager(any asyncManager)

    Parameters:
    asyncManager

    setDefaultProtocol

    public any setDefaultProtocol(string defaultProtocol)

    Parameters:
    defaultProtocol

    setDefaultSetting

    public MailService setDefaultSetting(any setting, [any value])

    Convenience method to set a default setting value

    Parameters:
    setting - The setting key to set
    value - The setting value to set

    setDefaultSettings

    public any setDefaultSettings(struct defaultSettings)

    Parameters:
    defaultSettings

    setInteceptorService

    public any setInteceptorService(any inteceptorService)

    Parameters:
    inteceptorService

    setLog

    public any setLog(any log)

    Parameters:
    log

    setMailQueue

    public any setMailQueue(any mailQueue)

    Parameters:
    mailQueue

    setMailers

    public any setMailers(struct mailers)

    Parameters:
    mailers

    setSettings

    public any setSettings(any settings)

    Parameters:
    settings

    setTokenMarker

    public any setTokenMarker(string tokenMarker)

    Parameters:
    tokenMarker

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    storeMailDefaults

    private MailService storeMailDefaults([any server], [any username], [any password], [numeric port], [any from], [any to], [any body], [any bcc], [any cc], [any charset], [boolean debug='false'], [any failto], [any group], [boolean groupcasesensitive], [any mailerid], [numeric maxrows], [any mimeattach], [any priority], [any query], [any replyto], [boolean spoolenable], [numeric startrow], [any subject], [numeric timeout], [any type], [boolean useSSL], [boolean useTLS], [numeric wraptext])

    Store the mail defaults

    Parameters:
    server
    username
    password
    port
    from
    to
    body
    bcc
    cc
    charset
    debug
    failto
    group
    groupcasesensitive
    mailerid
    maxrows
    mimeattach
    priority
    query
    replyto
    spoolenable
    startrow
    subject
    timeout
    type
    useSSL
    useTLS
    wraptext