models

Class Mail

lucee.Component
    extended by models.Mail

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ---- A mail payload object used by the developer to send mail via the mail services. You can use our dynamic getters and setters to set any property in the configuration structure that can be used by the sending transit protocol. Example: If we use the CFMail protocol then we can set ANY of the attributes that the cfmail tag uses into this configuration object. Then the transit object will use it accordingly.

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Luis Majano
  •  
    Property Summary
    type property default serializable required
    struct config
          The config struct representing the mail payload which is sent to the configured protocol in the mail service.

    • access = public
    • returntype = any
    true false
    string mailer
          The mailer to use when sending the payload.

    • access = public
    • returntype = any
    true false
    struct results
          The structure of results of sending the mail via the protocol.

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


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    Mail addAttachments(any files, [boolean remove='false'])
         Add attachment(s) to this payload using a list or array of file locations.
    Mail addMailParam([any contentID], [any disposition], [any file], [any type], [any name], [any value], [boolean remove], [any content])
         Add mail params to this payload.
    Mail addMailPart([any charset='utf-8'], [any type], [numeric wraptext], [any body])
         Add a new mail part to this mail payload.
    Mail config()
         Place holder for `configure()` as a compatibility shim.
    Mail configure([any from], [any to], [any body], [any bcc], [any cc], [any charset], [boolean debug], [any failto], [any group], [boolean groupcasesensitive], [any mailerid], [numeric maxrows], [any mimeattach], [any password], [numeric port], [any priority], [any query], [any replyto], [any server], [boolean spoolenable], [numeric startrow], [any subject], [numeric timeout], [any type], [any username], [boolean useSSL], [boolean useTLS], [numeric wraptext], [struct additionalInfo='[runtime expression]'], [any fromName])
         Seed the configuration of this object.
    any getAdditionalInfoItem(any key, [any defaultValue=''])
         Get the additional info stored by key.
    string getConfig()
    string getMailer()
    struct getMemento()
         Return the configuration structure.
    any getProperty(any property, [any defaultValue])
         Get a config property, throws an exception if not found.
    array getResultMessages()
         Get the result messages.
    string getResults()
    string getWirebox()
    boolean hasErrors()
         Check if the sending had errors or not.
    any onError(any callback)
         Callback that if there is an error in the sending of the mail it will be called for you.
    any onMissingMethod([any missingMethodName], [any missingMethodArguments='[runtime expression]'])
         Listen to dynamic getters and setters for any configuration setting:.
    any onSuccess(any callback)
         Callback that if there is NO error in the sending of the mail it will be called for you.
    boolean propertyExists(any property)
         Verifies if a config property exists or not.
    string queue()
         Queue the mail payload into our asynchronous work queue.
    Mail send()
         Send this mail payload and return itself.
    any sendAsync()
         Send this mail payload asynchronously and return a Future.
    Mail setAdditionalInfoItem(any key, any value)
         Store additional info items.
    any setConfig(struct config)
    Mail setHtml(any body)
         Sets up a mail part that is HTML using utf8 for you by calling addMailpart().
    any setMailer(string mailer)
    Mail setProperty(any property, any value)
         Set a config property with a value.
    Mail setReadReceipt(any email)
         Set the email address that will receive read receipts.
    any setResults(struct results)
    Mail setSendReceipt(any email)
         Sets the email that get's notified once the email is delivered by setting the appropriate mail headers.
    Mail setText(any body)
         Sets up a mail part that is TEXT using utf8 for you by calling addMailpart().
    Mail setView(any view, [struct args='[runtime expression]'], [any module=''], [any layout], [any layoutModule=''])
         Render or a view layout combination as the body for this email.
    any setWirebox(any wirebox)
    boolean validate()
         Validate that the basic fields of from, to, and body are set for sending mail.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    config

    property struct config

    The config struct representing the mail payload which is sent to the configured protocol in the mail service

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

    mailer

    property string mailer

    The mailer to use when sending the payload. It defaults to `default`

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

    results

    property struct results

    The structure of results of sending the mail via the protocol. At most it will contain the following keys: - error : boolean - messages : array of messages

    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

    addAttachments

    public Mail addAttachments(any files, [boolean remove='false'])

    Add attachment(s) to this payload using a list or array of file locations

    Parameters:
    files - A list or array of files to attach to this payload
    remove - If true, ColdFusion removes attachment files (if any) after the mail is successfully delivered.

    addMailParam

    public Mail addMailParam([any contentID], [any disposition], [any file], [any type], [any name], [any value], [boolean remove], [any content])

    Add mail params to this payload

    Parameters:
    contentID
    disposition
    file
    type
    name
    value
    remove
    content

    addMailPart

    public Mail addMailPart([any charset='utf-8'], [any type], [numeric wraptext], [any body])

    Add a new mail part to this mail payload

    Parameters:
    charset
    type
    wraptext
    body

    config Deprecated

    public Mail config()

    Place holder for `configure()` as a compatibility shim

    Deprecated:
    This will be removed

    configure

    public Mail configure([any from], [any to], [any body], [any bcc], [any cc], [any charset], [boolean debug], [any failto], [any group], [boolean groupcasesensitive], [any mailerid], [numeric maxrows], [any mimeattach], [any password], [numeric port], [any priority], [any query], [any replyto], [any server], [boolean spoolenable], [numeric startrow], [any subject], [numeric timeout], [any type], [any username], [boolean useSSL], [boolean useTLS], [numeric wraptext], [struct additionalInfo='[runtime expression]'], [any fromName])

    Seed the configuration of this object

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

    getAdditionalInfoItem

    public any getAdditionalInfoItem(any key, [any defaultValue=''])

    Get the additional info stored by key

    Parameters:
    key - The key to get
    defaultValue - The default value if not found, defaults to empty string

    getConfig

    public string getConfig()


    getMailer

    public string getMailer()


    getMemento Deprecated

    public struct getMemento()

    Return the configuration structure

    Deprecated:
    This will be dropped do not use anymore, use getConfig()

    getProperty

    public any getProperty(any property, [any defaultValue])

    Get a config property, throws an exception if not found.

    Parameters:
    property - The property to get
    defaultValue - The default value to retrieve if property doesn't exist
    Throws:
    PropertyNotFoundException if the property doesn't exist

    getResultMessages

    public array getResultMessages()

    Get the result messages


    getResults

    public string getResults()


    getWirebox

    public string getWirebox()


    hasErrors

    public boolean hasErrors()

    Check if the sending had errors or not


    onError

    public any onError(any callback)

    Callback that if there is an error in the sending of the mail it will be called for you. The callback will receive the results struct and the mail object itself

    Parameters:
    callback

    onMissingMethod

    public any onMissingMethod([any missingMethodName], [any missingMethodArguments='[runtime expression]'])

    Listen to dynamic getters and setters for any configuration setting:

    getFrom()
    getFrom( "defaultValue" )
    setFrom( "luis@ortussolutions.com" )
    setFrom() => empty value, same as setFrom( "" )
    

    Parameters:
    missingMethodName
    missingMethodArguments

    onSuccess

    public any onSuccess(any callback)

    Callback that if there is NO error in the sending of the mail it will be called for you. The callback will receive the results struct and the mail object itself

    Parameters:
    callback

    propertyExists

    public boolean propertyExists(any property)

    Verifies if a config property exists or not

    Parameters:
    property - The property key

    queue

    public string queue()

    Queue the mail payload into our asynchronous work queue

    Returns:
    A unique identifier for the task that was registered for you.

    send

    public Mail send()

    Send this mail payload and return itself


    sendAsync

    public any sendAsync()

    Send this mail payload asynchronously and return a Future


    setAdditionalInfoItem

    public Mail setAdditionalInfoItem(any key, any value)

    Store additional info items

    Parameters:
    key - The key to store
    value - The value to store

    setConfig

    public any setConfig(struct config)

    Parameters:
    config

    setHtml

    public Mail setHtml(any body)

    Sets up a mail part that is HTML using utf8 for you by calling addMailpart()

    Parameters:
    body - The body content to set the mail part on

    setMailer

    public any setMailer(string mailer)

    Parameters:
    mailer

    setProperty

    public Mail setProperty(any property, any value)

    Set a config property with a value

    Parameters:
    property - The property key
    value - The property value

    setReadReceipt

    public Mail setReadReceipt(any email)

    Set the email address that will receive read receipts. I just place the appropriate mail headers

    Parameters:
    email - The email to send the read recipt to

    setResults

    public any setResults(struct results)

    Parameters:
    results

    setSendReceipt

    public Mail setSendReceipt(any email)

    Sets the email that get's notified once the email is delivered by setting the appropriate mail headers

    Parameters:
    email - The email to send the send recipt to

    setText

    public Mail setText(any body)

    Sets up a mail part that is TEXT using utf8 for you by calling addMailpart()

    Parameters:
    body - The body content to set the mail part on

    setView

    public Mail setView(any view, [struct args='[runtime expression]'], [any module=''], [any layout], [any layoutModule=''])

    Render or a view layout combination as the body for this email. If you use this, the `type` of the email will be set to `html` as well. You can also bind the view/layout with the args struct and use them accordingly. You can also use body tokens that the service will replace for you at runtime.

    Parameters:
    view - The view to render as the body
    args - The structure of arguments to bind the view/layout with
    module - Optional, the module the view is located in
    layout - Optional, If passed, we will render the view in this layout
    layoutModule - Optional, If passed, the module the layout is in

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    validate

    public boolean validate()

    Validate that the basic fields of from, to, and body are set for sending mail