Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Accounts
  • Actions
  • ApiKeys
  • Backup
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CouponTerms
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • EmailVerifications
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • MessageGroups
  • Messages
  • MessengerManager
  • ModuleClientMeta
  • ModuleManager
  • ModuleTypes
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • ServiceInvoices
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • SystemEvents
  • Taxes
  • Themes
  • Transactions
  • Users
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class Emails

Email management

Model
Extended by AppModel uses Blesta\Core\Util\Common\Traits\Container
Extended by Emails
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/emails.php
Methods summary
public
# __construct( )

Initialize Emails

Initialize Emails

Overrides

AppModel::__construct()
public mixed
# get( integer $id )

Retrieves a single email template by ID, including email group tags

Retrieves a single email template by ID, including email group tags

Parameters

$id
The ID of the email template to fetch

Returns

mixed
A stdClass object representing the email template, false if no such template exists
public mixed
# getByGroupId( integer $group_id, string $lang = null )

Retrieves a signle email template by Group ID for the current company

Retrieves a signle email template by Group ID for the current company

Parameters

$group_id
The email group ID to use to fetch the email tempalte for the current company
$lang

The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) (optional, defaults to default language)

Returns

mixed
A stdClass object representing the email template, false if no such template exists
public mixed
# getByType( integer $company_id, string $action, string $lang = null )

Fetches a single email template by company ID, type, and (optionally) language

Fetches a single email template by company ID, type, and (optionally) language

Parameters

$company_id
The ID of the company to fetch the email for
$action
The email group action to fetch
$lang
The language of template to fetch, defaults to default language

Returns

mixed
A stdClass object representing the email template, false if no such template exists
public mixed
# getList( integer $company_id, string $email_group_id )

Fetches a list of all email templates under a company for the given email group in every available language

Fetches a list of all email templates under a company for the given email group in every available language

Parameters

$company_id
The company ID to fetch email templates for
$email_group_id
The email group ID

Returns

mixed
An array of objects or false if no results.
public integer
# add( array $vars )

Adds an email with the given data

Adds an email with the given data

Parameters

$vars

An array of email info including: - email_group_id The ID of the group this email belongs to - company_id The company ID this email belongs to - lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) (optional, default en_us) - from The address the message will be sent from - from_name The name belonging to the from address - subject The subject of the message - text The plain-text body of the message (if empty will be created based on the html content) (optional, default null) - html The html body of the message (optional, default null) - email_signature_id The signature to append to the email (optional, default null) - include_attachments 1 to include attachments when the email is sent, 0 to not send attachments with the email (optional, default 1) - status The status of this email 'active', 'inactive' (optional, default active)

Returns

integer
The ID of the email, void on error
public
# edit( integer $id, array $vars )

Updates the email with the given data

Updates the email with the given data

Parameters

$id
The ID of the email to update
$vars

An array of email info including: - email_group_id The ID of the group this email belongs to - company_id The company ID this email belongs to - lang The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) (optional, default en_us) - from The address the message will be sent from - from_name The name belonging to the from address - subject The subject of the message - text The plain-text body of the message (if empty will be created based on the html content) (optional, default null) - html The html body of the message (optional, default null) - email_signature_id The signature to append to the email (optional, default null) - include_attachments 1 to include attachments when the email is sent, 0 to not send attachments with the email (optional) - status The status of this email 'active', 'inactive' (optional, default active)

public
# delete( integer $id )

Permanently removes the email from the system.

Permanently removes the email from the system.

Parameters

$id
The ID of the email to delete
public
# deleteAll( integer $email_group_id, integer $company_id )

Permanently removes all email templates of the given group from the system.

Permanently removes all email templates of the given group from the system.

Parameters

$email_group_id
The ID of the email group to remove all email template from
$company_id
The ID of the company to remove all email templates in this group
public
# updateFromDomain( string $domain, integer $company_id )

Updates the domani portion of the from name for every email in the given company.

Updates the domani portion of the from name for every email in the given company.

Parameters

$domain
The new domain to use
$company_id
The ID of the company to update
public array
# getStatusTypes( )

Retrieves a list of email status types

Retrieves a list of email status types

Returns

array
Key=>value pairs of email status types
public
# addSignature( array $vars )

Adds the given signature to the system

Adds the given signature to the system

Parameters

$vars

An array of signature info including: - company_id The company ID to create the signature under - name The name of the signature - text The plaintext signature - html The HTML signature

public
# editSignature( $email_signature_id, array $vars )

Updates an existing signature in the system

Updates an existing signature in the system

Parameters

$email_signature_id
ID of the signature in the system to update
$vars

An array of signature info including: - name The name of the signature - text The plaintext signature - html The HTML signature

public
# deleteSignature( integer $email_signature_id )

Permanently removes an email signature from the system

Permanently removes an email signature from the system

Parameters

$email_signature_id
The ID of the email signature to delete
public mixed
# getSignature( integer $email_signature_id )

Fetches an email signature

Fetches an email signature

Parameters

$email_signature_id
The email signature ID

Returns

mixed
An array of objects or false if no results.
public array
# getSignatureList( integer $company_id, integer $page = 1, string $order_by = ['name' => 'ASC'] )

Fetches a list of all email signatures for a given company

Fetches a list of all email signatures for a given company

Parameters

$company_id
The company ID whose signatures to fetch
$page
The page to return results for (optional, default 1)
$order_by
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)

Returns

array
An array of objects or false if no results.
public integer
# getSignatureListCount( integer $company_id )

Fetches the total number of signatures returned from Emails::getSignatureList(), useful in constructing pagination for the getSignatureList() method.

Fetches the total number of signatures returned from Emails::getSignatureList(), useful in constructing pagination for the getSignatureList() method.

Parameters

$company_id
The company ID whose signatures to fetch

Returns

integer
The total number of signatures

See

Emails::getList()
public array
# getAllSignatures( integer $company_id )

Retrieves a list of all signatures for this company

Retrieves a list of all signatures for this company

Parameters

$company_id
The company ID whose signatures to fetch

Returns

array
An array of stdClass objects each representing a signature
public mixed
# getGroup( integer $email_group_id )

Fetches an email group

Fetches an email group

Parameters

$email_group_id
The email group ID

Returns

mixed
An array of objects or false if no results.
public
# getGroupList( string $sortby = 'action', string $order = 'asc' )

Fetches all email groups

Fetches all email groups

Parameters

$sortby
$sort_by The field to sort by
$order
The direction to order (asc, desc)
public boolean
# send( string $action, integer $company_id, string $lang, mixed $to, array $tags = null, mixed $cc = null, mixed $bcc = null, array $attachments = null, array $options = null )

Sends the given email using the criteria specified

Sends the given email using the criteria specified

Parameters

$action
The action that specifies the email group to use
$company_id
The company ID to send this email under
$lang

The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) to send, if no message found for this language will attempt to send using company's default language

$to
The To address(es) to send to. A string, or an array of email addresses
$tags

An array of replacement tags containing the key/value pairs for the replacements where the key is the tag to replace and the value is the value to replace it with

$cc
The CC address(es) to send to. A string, or an array of email addresses
$bcc
The BCC address(es) to send to. A string, or an array of email addresses
$attachments

A multi-dimensional array of attachments containing: - path The path to the attachment on the file system - name The name of the attachment (optional, default '') - encoding The file encoding (optional, default 'base64') - type The type of attachment (optional, default 'application/octet-stream')

$options

An array of options including: - to_client_id The ID of the client the message was sent to - from_staff_id The ID of the staff member the message was sent from - from The from address - from_name The from name - reply_to The reply to address - log Whether or not to log the email (default true) - log_masked_tags The tags to be masked when logging the email

Returns

boolean
Returns true if the message was successfully sent, false otherwise
public boolean
# sendCustom( string $from, string $from_name, mixed $to, string $subject, array $body, array $tags = null, mixed $cc = null, mixed $bcc = null, array $attachments = null, array $options = null )

Sends a custom email using the criteria specified

Sends a custom email using the criteria specified

Parameters

$from
The email address to send from.
$from_name
The name to send from.
$to
The To address(es) to send to. A string, or an array of email addresses
$subject

The subject of the message. Tags provided in the subject will be evaluated by the template parser

$body

An array containing the body in HTML and text of the email. Tags provided in the body will be evaluated by the template parser: - html The HTML version of the email (optional) - text The text version of the email (optional)

$tags

An array of replacement tags containing the key/value pairs for the replacements where the key is the tag to replace and the value is the value to replace it with

$cc

The CC address(es) to send to. A string, or an array of email addresses

$bcc

The BCC address(es) to send to. A string, or an array of email addresses

$attachments

A multi-dimensional array of attachments containing: - path The path to the attachment on the file system - name The name of the attachment (optional, default '') - encoding The file encoding (optional, default 'base64') - type The type of attachment (optional, default 'application/octet-stream')

$options

An array of options including: - to_client_id The ID of the client the message was sent to - from_staff_id The ID of the staff member the message was sent from - reply_to The reply to address - log Whether or not to log the email (default true) - log_masked_tags The tags to be masked when logging the email

Returns

boolean
Returns true if the message was successfully sent, false otherwise
public mixed
# buildEmail( string $action, integer $company_id, string $lang, array $tags = null )

Parses an Email stdClass object using the given data ($tags)

Parses an Email stdClass object using the given data ($tags)

Parameters

$action
The action that specifies the email group to use
$company_id
The company ID to send this email under
$lang

The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) to send, if no message found for this language will attempt to send using company's default language

$tags

An array of replacement tags containing the key/value pairs for the replacements where the key is the tag to replace and the value is the value to replace it with

Returns

mixed

A stdClass object representing the parsed email template, false if no such template exists

public boolean
# validateEmailGroupAction( string $action )

Validates that the given action is a valid email group action

Validates that the given action is a valid email group action

Parameters

$action
The email group action

Returns

boolean
True if the action is valid, false otherwise
public boolean
# validateEmailAddresses( mixed $email_addresses )

Validates that each of the given email addresses provided are valid

Validates that each of the given email addresses provided are valid

Parameters

$email_addresses
string representing a single email address, or an array of email addresses

Returns

boolean
True if every email address is valid, false otherwise
public
# validateAttachmentPaths( $attachments )

Validates that the given attachments exist on the file system

Validates that the given attachments exist on the file system

public boolean
# validateStatus( string $status )

Validates the emails 'status' field

Validates the emails 'status' field

Parameters

$status
The status to check

Returns

boolean
True if status validated, false otherwise
public boolean
# validateSignatureExists( integer $signature_id, integer $company_id = null )

Validates the email signature submitted exists and belongs to the company ID given

Validates the email signature submitted exists and belongs to the company ID given

Parameters

$signature_id
The email signature ID
$company_id
The company ID (optional)

Returns

boolean
True if the signature exists and belongs to the company ID given, false otherwise
public boolean
# validateSignatureInUse( integer $signature_id )

Checks whether the email signature given is in use by any email

Checks whether the email signature given is in use by any email

Parameters

$signature_id
The email signature ID

Returns

boolean
True if signature ID is in use, false otherwise
public boolean
# validateUnique( integer $company_id, integer $email_group_id, string $lang )

Validates the given company ID, email group ID, and language type are unique for this email

Validates the given company ID, email group ID, and language type are unique for this email

Parameters

$company_id
The company ID
$email_group_id
The email group ID
$lang

The language in ISO 636-1 2-char + "_" + ISO 3166-1 2-char (e.g. en_us) (optional, default en_us)

Returns

boolean
True if the given info is unique, false otherwise
public
# validateParse( string $str )

Validate that the given string parses template parsing

Validate that the given string parses template parsing

Parameters

$str
The string to test
Methods inherited from AppModel
_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()
Methods used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties inherited from AppModel
$logger, $replacement_keys
Blesta API documentation generated by ApiGen