Message
An Email Message
Messages are sent out for various reasons, including for events such as invoice creation and Email Campaigns.
The Message class allows you to interact with the message to update any respective properties before use.
Constants
| HEADER_MARKER | 
 | 
| FOOTER_MARKER | 
 | 
| RECIPIENT_TYPES | 
 | 
Properties summary
| Type | Property | Description | |
|---|---|---|---|
| protected | $type | ||
| protected | $templateName | ||
| protected | $from | ||
| protected | $to | ||
| protected | $cc | ||
| protected | $bcc | ||
| protected | $replyTo | ||
| protected | $subject | ||
| protected | $body | ||
| protected | $bodyPlainText | ||
| protected | $attachments | 
Methods summary
| Return Type | Method Name | Description | |
|---|---|---|---|
| __construct() | - | ||
| $this | setEmailLogId($id) | Set the ID of the email relative to tblemails.id | |
| static Message | createFromTemplate(Template $template) | Build an Email Message from a predefined Template | |
| $this | setType(string $type) | Set the Email Type. e.g. 'general' | |
| string | getType() | Retrieve the Message type | |
| $this | setTemplateName(string $templateName) | Set the Message template name | |
| string | getTemplateName() | Retrieve the Message template name | |
| $this | addRecipient(string $kind, string $email, string $name = '') | Add a recipient for the Message | |
| $this | clearRecipients(string $kind) | Clear recipients for a specific kind | |
| $this | setFromName(string $name) | Set the "From" name for the Message | |
| string | getFromName() | Retrieve the "From" name for the message | |
| $this | setFromEmail(string $email) | Set the sender Email Address for the Message | |
| mixed | getFromEmail() | Retrieve the sender Email Address for the Message | |
| string | getFormattedFrom() | Retrieve the sender Email Address and Name formatted for sending. e.g. 'John Doejohn@example.net' | |
| $this | setReplyTo(string $email, string $name = '') | Set the Reply To address and name for the Message | |
| array | getReplyTo() | Retrieve the Reply To address and name for the Message | |
| array | getRecipients(string $kind) | Retrieve the recipients for the Message | |
| array|string | getFormattedRecipients($kind) | Retrieve the sender Email Addresses and Names formatted for sending. e.g. 'John Doe john@example.net' | |
| $this | setSubject(string $subject) | Set the subject of the Message | |
| string | getSubject() | Retrieve the subject of the Message | |
| $this | setBodyAndPlainText(string $body) | Set the Message body. Providing HTML will set both HTML and Plain-Text | |
| $this | setBody(string $body) | Set the HTML body of the Message | |
| $this | setBodyFromSmarty(string $body) | Set the Message body from a parsed Smarty template | |
| string | getBody() | Retrieve the HTML body of the Message | |
| string | getBodyWithoutCSS() | Retrieve the HTML body of the Message without Global CSS included | |
| $this | setPlainText(string $text) | Set the Plain-Text body of the Message | |
| string | replaceLinksWithUrl(string $text) | Replace links for the plain text version with just the href | |
| string | getPlainText() | Retrieve the Plain-Text body of the Message | |
| $this | addStringAttachment(string $filename, string $data) | Add string attachment | |
| $this | addFileAttachment(string $filename, string $filepath) deprecated | Add attachment from file system | |
| array | getAttachments() | Retrieve attachments for the Message | |
| array | getAttachmentNames() | Retrieve the filenames for attachments associated with the Message | |
| bool | hasRecipients() | Check if the Message has at least one recipient defined | |
| int | saveToEmailLog(int $userId) | Save the Message to the Email Log | |
| setGlobalBCCRecipients() | - | 
Details
                            
    __construct ()
        
    
    
                            $this
    setEmailLogId ($id)
        
    
    Set the ID of the email relative to tblemails.id
                static            Message
    createFromTemplate (Template $template)
        
    
    Build an Email Message from a predefined Template
                            $this
    setType (string $type)
        
    
    Set the Email Type. e.g. 'general'
                            string
    getType ()
        
    
    Retrieve the Message type
                            $this
    setTemplateName (string $templateName)
        
    
    Set the Message template name
                            string
    getTemplateName ()
        
    
    Retrieve the Message template name
                            $this
    addRecipient (string $kind, string $email, string $name = '')
        
    
    Add a recipient for the Message
                            $this
    clearRecipients (string $kind)
        
    
    Clear recipients for a specific kind
                            $this
    setFromName (string $name)
        
    
    Set the "From" name for the Message
                            string
    getFromName ()
        
    
    Retrieve the "From" name for the message
                            $this
    setFromEmail (string $email)
        
    
    Set the sender Email Address for the Message
                            mixed
    getFromEmail ()
        
    
    Retrieve the sender Email Address for the Message
                            string
    getFormattedFrom ()
        
    
    Retrieve the sender Email Address and Name formatted for sending. e.g. 'John Doejohn@example.net'
                            $this
    setReplyTo (string $email, string $name = '')
        
    
    Set the Reply To address and name for the Message
                            array
    getReplyTo ()
        
    
    Retrieve the Reply To address and name for the Message
                            array
    getRecipients (string $kind)
        
    
    Retrieve the recipients for the Message
                            array|string
    getFormattedRecipients ($kind)
        
    
    Retrieve the sender Email Addresses and Names formatted for sending. e.g. 'John Doe john@example.net'
                            $this
    setSubject (string $subject)
        
    
    Set the subject of the Message
                            string
    getSubject ()
        
    
    Retrieve the subject of the Message
                            $this
    setBodyAndPlainText (string $body)
        
    
    Set the Message body. Providing HTML will set both HTML and Plain-Text
                            $this
    setBody (string $body)
        
    
    Set the HTML body of the Message
                            $this
    setBodyFromSmarty (string $body)
        
    
    Set the Message body from a parsed Smarty template
                            string
    getBody ()
        
    
    Retrieve the HTML body of the Message
                            string
    getBodyWithoutCSS ()
        
    
    Retrieve the HTML body of the Message without Global CSS included
                            $this
    setPlainText (string $text)
        
    
    Set the Plain-Text body of the Message
                    protected        string
    replaceLinksWithUrl (string $text)
        
    
    Replace links for the plain text version with just the href
                            string
    getPlainText ()
        
    
    Retrieve the Plain-Text body of the Message
                            $this
    addStringAttachment (string $filename, string $data)
        
    
    Add string attachment
                            $this
    addFileAttachment (string $filename, string $filepath)
        deprecated
    
    deprecated
Add attachment from file system
                            array
    getAttachments ()
        
    
    Retrieve attachments for the Message
                            array
    getAttachmentNames ()
        
    
    Retrieve the filenames for attachments associated with the Message
                            bool
    hasRecipients ()
        
    
    Check if the Message has at least one recipient defined
                            int
    saveToEmailLog (int $userId)
        
    
    Save the Message to the Email Log