\CGExtensions\EmailSimpleEmailProcessor

A class to act as a processor for Email objects.

When this object sends messages it tries to use some intelligence so that the same email is not sent to the same user twice.

This class has no mechanism for sending messages in batches.

Summary

Methods
Properties
Constants
__construct()
before_send()
after_send()
on_error()
get_email_subject()
get_email_body()
send()
No public properties found
No constants found
resolve_dest_addresses()
resolve_cc_emails()
resolve_bcc_emails()
get_template()
process_one_email()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(\CGExtensions\Email\Email  $eml, \cms_mailer  $mailer) 

Constructor

Parameters

\CGExtensions\Email\Email $eml

The email object that will be used to send messaage.

\cms_mailer $mailer

The mailer object to use.

before_send()

before_send(callable  $c) : void

Set a callback to be executed before each message is compiled and sent.

The callback function should accept two parameters. An Email object, and an EmailDest object. It should return an email object.

Parameters

callable $c

The callback

after_send()

after_send(callable  $c) : void

Set a callback to be executed after each message is compiled and successfuly sent.

The callback function should accept two parameters. An Email object, and an EmailDest object. It should return an email object.

Parameters

callable $c

The callback

on_error()

on_error(callable  $c) : void

Set a callback to be executed when sending a message fails.

The callback function should accept two parameters. An EmailDest object, and an error string.

Parameters

callable $c

The callback

get_email_subject()

get_email_subject(\CGExtensions\Email\Email  $eml) : string

Given an email object, get the rendered subject.

Parameters

\CGExtensions\Email\Email $eml

Returns

string

get_email_body()

get_email_body(\CGExtensions\Email\Email  $eml) : string

Given an email obbject, get the processed body.

Parameters

\CGExtensions\Email\Email $eml

Returns

string

send()

send() : void

Process and send the email

It is the responsibility of the class to accept an Email object in its constructor, or otherwise.

resolve_dest_addresses()

resolve_dest_addresses() : array<mixed,\CGExtensions\Email\EmailDestination>

Get a list of all addresses that the current email should be sent to.

Returns

array<mixed,\CGExtensions\Email\EmailDestination>

resolve_cc_emails()

resolve_cc_emails() : array<mixed,\CGExtensions\Email\EmailDestination>

Get a list of all addresses that the current email should be CC'd to

Returns

array<mixed,\CGExtensions\Email\EmailDestination>

resolve_bcc_emails()

resolve_bcc_emails() : array<mixed,\CGExtensions\Email\EmailDestination>

Get a list of all addresses that the current email should be BCC'd to

Returns

array<mixed,\CGExtensions\Email\EmailDestination>

get_template()

get_template(\CGExtensions\Email\Email  $eml) : \CGExtensions\Email\smarty_template

Given an email object, get a smarty template to allow processing it.

This method assigns all data in the email object to smarty variables.

Parameters

\CGExtensions\Email\Email $eml

Returns

\CGExtensions\Email\smarty_template —

A smarty template object