Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • CampaignMailingBehavior
  • Overview
  • Package
  • Class
  • Tree

Class CampaignMailingBehavior

Behavior class for email delivery in email marketing campaigns.

Static methods are used for batch emailing; all non-static methods assume that an individual email is being sent.

CComponent
Extended by CBehavior implements IBehavior
Extended by EmailDeliveryBehavior
Extended by CampaignMailingBehavior
Package: application\modules\marketing\components
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/modules/marketing/components/CampaignMailingBehavior.php
Methods summary
public static type
# prepareEmail( Campaign $campaign, Contacts $contact, type $replaceBreaks = true, boolean $replaceUnsubToken = true )

Prepares the subject and body of a campaign email.

Prepares the subject and body of a campaign email.

Any and all features of the campaign that are dynamically added at the last minute to the email body are added in this method right before the sending of the email.

Returns an array;

First element: email subject Second element: email body Third element: unique ID assigned to the current email

Parameters

$campaign
Campaign
$campaign Campaign of the current email being sent
$contact
Contacts
$contact Contact to whom the email is being sent
$replaceBreaks
type
$email
$replaceUnsubToken
boolean
$replaceBreaks used for unit testing

Returns

type

Throws

Exception
public static
# emailLockFile( )
public static
# lockEmail( mixed $lock = true )
public static
# emailIsLocked( )

Mediates lockfile checking.

Mediates lockfile checking.

public static array
# deliverableItems( integer $listId, boolean $unsent = false )

For a given list ID, find all contact/list item entries such that sending is possible, is permissible, or has happened.

For a given list ID, find all contact/list item entries such that sending is possible, is permissible, or has happened.

The criteria are:

  • x2_list_item.listId matches the list being operated on
  • x2_list_item.unsubscribed and x2_contacts.doNotEmail are both zero (contact has not specified that email is unwelcome)
  • One of x2_list_item.emailAddress or x2_contacts.email is non-empty, so that there is actually an email address to send to

Parameters

$listId
integer
$listId The ID of the list operating on
$unsent
boolean
$unsent Constrain (if true) the query to unsent entries.

Returns

array
An array containing the "id", "sent" and "uniqueId" columns.
public static
# recordEmailSent( Campaign $campaign, Contacts $contact )
public type
# getCampaign( )

Campaign model for this e-mail

Campaign model for this e-mail

Returns

type
public type
# getCredId( )

Credentials record to be used. Overrides EmailDeliveryBehavior::sendAs in order to configure SMTP delivery.

Credentials record to be used. Overrides EmailDeliveryBehavior::sendAs in order to configure SMTP delivery.

Returns

type

Overrides

EmailDeliveryBehavior::getCredId()
public
# getIsNewsletter( )
public
# getList( )

Getter for list

Getter for list

public
# getListItem( )

Getter for listItem

Getter for listItem

public type
# getRecipient( )

Getter for recipient

Getter for recipient

Returns

type
public boolean
# mailIsStillDeliverable( )

One final check for whether the mail should be sent, and enable the 'sending' flag.

One final check for whether the mail should be sent, and enable the 'sending' flag.

This is a safeguard for the use case of batch emailing when a user subscribes or a value in the database changes between loading the list items to deliver and when the actual delivery takes place.

Returns

boolean
True if we're clear to send; false otherwise.
public
# markEmailSent( type $uniqueId, boolean $sent = true )

Records the date of delivery and marks the list record with the unique id.

Records the date of delivery and marks the list record with the unique id.

This method will not just update the current list item; it selects all list items if their email address and list ID are the same. This is to avoid sending duplicate messages.

If mail is non-deliverable, it should still be marked as sent but with a null unique ID, to designate it as a bad email address.

Parameters

$uniqueId
type
$uniqueId
$sent
boolean
$unsent If false, perform the opposite operation (mark as not currently sending).
public
# sendIndividualMail( )

Send an email.

Send an email.

public
# setCampaign( Campaign $value )
public static
# sendMail( integer $id = null, mixed $t0 = null )

Send mail for any active campaigns, in a batch.

Send mail for any active campaigns, in a batch.

This method is made public and static to allow it to be called from elsewhere, without instantiation.

Parameters

$id
integer
$id The ID of the campaign to return status messages for
$t0
protected static Array
# campaignMailing( Campaign $campaign, integer $limit = null )

Send mail for one campaign

Send mail for one campaign

Parameters

$campaign
Campaign
$campaign The campaign to send
$limit
integer
$limit The maximum number of emails to send

Returns

Array
[0]=> The number of emails sent, [1]=> array of applicable error messages
Methods inherited from EmailDeliveryBehavior
addEmailAddresses(), addressHeaderToArray(), clearTemporaryFiles(), deliverEmail(), getCredentials(), getDebugStatus(), getFrom(), getMailer(), getUserProfile(), setCredId(), setFrom(), setUserProfile(), testUserCredentials(), validateFileSize()
Methods inherited from CBehavior
attach(), detach(), events(), getEnabled(), getOwner(), setEnabled()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
string EMLLOCK 'campaign_emailing.lock'
#

Filename of lock file in protected/runtime, to signal that emailing is already in progress and other processes should not attempt to send email (as this may result in race conditions and duplicate emails)

Filename of lock file in protected/runtime, to signal that emailing is already in progress and other processes should not attempt to send email (as this may result in race conditions and duplicate emails)

integer STATE_BULKLIMIT 1
#

Error code for the bulk limit being reached

Error code for the bulk limit being reached

integer STATE_RACECOND 2
#

Error code for an email already sending.

Error code for an email already sending.

integer STATE_NULLADDRESS 3
#

Error code for an item whose address has suddenly gone blank

Error code for an item whose address has suddenly gone blank

integer STATE_DONOTEMAIL 4
#

Error code for an unsubscribed / do-not-email contact

Error code for an unsubscribed / do-not-email contact

integer STATE_SENT 5
#

Error code for another email process beating us to the punch

Error code for another email process beating us to the punch

Properties summary
public static type $batchTime
#

Stores the time that the batch operation started (when calling this class' methods statically)

Stores the time that the batch operation started (when calling this class' methods statically)

public Campaign $_campaign
#

The current campaign model being operated on

The current campaign model being operated on

public type $fullStop false
#

Whether the campaign mailing process should halt as soon as possible

Whether the campaign mailing process should halt as soon as possible

public integer $itemId
#

The ID of the campaign list item corresponding to the current recipient.

The ID of the campaign list item corresponding to the current recipient.

public boolean $stateChange false
#

Indicates whether the mail cannot be sent due to a recent change in the list item or contact record.

Indicates whether the mail cannot be sent due to a recent change in the list item or contact record.

public integer $stateChangeType 0
#

Indicates the type of state change that should block email delivery. This purpose is not relegated to EmailDeliveryBehavior::$status ("code" element) because that array is intended for PHPMailer codes.

Indicates the type of state change that should block email delivery. This purpose is not relegated to EmailDeliveryBehavior::$status ("code" element) because that array is intended for PHPMailer codes.

public boolean $undeliverable false
#

Whether the current email could not be delivered due to bad RCPT or something that's not a critical PHPMailer error

Whether the current email could not be delivered due to bad RCPT or something that's not a critical PHPMailer error

Properties inherited from EmailDeliveryBehavior
$status
Magic properties summary
public Campaign $campaign
#

Campaign model for the current email

Campaign model for the current email

public boolean $isNewsletter
#

True if sending to a newsletter list (not a contacts list)

True if sending to a newsletter list (not a contacts list)

public X2List $list
#

The list corresponding to the current campaign being operated on

The list corresponding to the current campaign being operated on

public X2ListItem $listItem
#

List item of the

List item of the

public Contacts $recipient
#

The contact of the current recipient that the email is being sent to. If it's not a campaign, but a newsletter, this will be an ad-hoc contact model with its email address set to that of the list item.

The contact of the current recipient that the email is being sent to. If it's not a campaign, but a newsletter, this will be an ad-hoc contact model with its email address set to that of the list item.

Magic properties inherited from EmailDeliveryBehavior
$credentials, $from, $mailer, $userProfile
Magic properties inherited from CBehavior
$enabled, $owner
X2CRM Documentation API documentation generated by ApiGen 2.8.0