Overview

Namespaces

  • Charcoal
    • Email
      • Script
      • ServiceProvider

Classes

  • Email
  • EmailConfig
  • EmailLog
  • EmailQueueItem
  • EmailQueueManager
  • GenericEmailTemplate

Interfaces

  • EmailInterface

Traits

  • EmailAwareTrait
  • Overview
  • Namespace
  • Class

Class Email

Default implementation of the EmailInterface.

Charcoal\Email\Email implements Charcoal\Config\ConfigurableInterface, Charcoal\Email\EmailInterface, Psr\Log\LoggerAwareInterface, Charcoal\Queue\QueueableInterface, Charcoal\View\ViewableInterface uses Charcoal\Config\ConfigurableTrait (not available) Psr\Log\LoggerAwareTrait (not available) Charcoal\Queue\QueueableTrait (not available) Charcoal\View\ViewableTrait (not available) Charcoal\Email\EmailAwareTrait
Namespace: Charcoal\Email
Located at Charcoal/Email/Email.php
Methods summary
public
# __construct( array $data )

Construct a new Email object.

Construct a new Email object.

Parameters

$data
Dependencies and settings.
protected Charcoal\Email\Email
# setTemplateFactory( Charcoal\Factory\FactoryInterface $factory )

Parameters

$factory
The factory to use to create email template objects.

Returns

Charcoal\Email\Email
Chainable
protected Charcoal\Factory\FactoryInterface
# templateFactory( )

Returns

Charcoal\Factory\FactoryInterface
protected Charcoal\Email\Email
# setQueueItemFactory( Charcoal\Factory\FactoryInterface $factory )

Parameters

$factory
The factory to use to create email queue item objects.

Returns

Charcoal\Email\Email
Chainable
protected Charcoal\Factory\FactoryInterface
# queueItemFactory( )

Returns

Charcoal\Factory\FactoryInterface
protected Charcoal\Email\Email
# setLogFactory( Charcoal\Factory\FactoryInterface $factory )

Parameters

$factory
The factory to use to create log objects.

Returns

Charcoal\Email\Email
Chainable
protected Charcoal\Factory\FactoryInterface
# logFactory( )

Returns

Charcoal\Factory\FactoryInterface
public Charcoal\Email\Email
# setData( array $data )

Set the email's data.

Set the email's data.

Parameters

$data
The data to set.

Returns

Charcoal\Email\Email
Chainable

Implementation of

Charcoal\Email\EmailInterface::setData()
public Charcoal\Email\EmailInterface
# setCampaign( string $campaign )

Set the campaign ID.

Set the campaign ID.

Parameters

$campaign
The campaign identifier.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the campaign is invalid.

Implementation of

Charcoal\Email\EmailInterface::setCampaign()
public string
# campaign( )

Get the campaign identifier.

Get the campaign identifier.

If it has not been explicitely set, it will be auto-generated (with uniqid).

Returns

string

Implementation of

Charcoal\Email\EmailInterface::campaign()
protected string
# generateCampaign( )

Generates a unique identifier ideal for a campaign ID.

Generates a unique identifier ideal for a campaign ID.

Returns

string
public Charcoal\Email\EmailInterface
# setTo( string|array $email )

Set the recipient email address(es).

Set the recipient email address(es).

Parameters

$email
The recipient email address(es).

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::setTo()
public Charcoal\Email\EmailInterface
# addTo( mixed $email )

Add a recipient email address.

Add a recipient email address.

Parameters

$email
The recipient email address to add.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::addTo()
public string[]
# to( )

Get the recipient's email address.

Get the recipient's email address.

Returns

string[]

Implementation of

Charcoal\Email\EmailInterface::to()
public Charcoal\Email\EmailInterface
# setCc( string|array $email )

Set the carbon copy (CC) recipient email address(es).

Set the carbon copy (CC) recipient email address(es).

Parameters

$email
The CC recipient email address(es).

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::setCc()
public Charcoal\Email\EmailInterface
# addCc( mixed $email )

Add a CC recipient email address.

Add a CC recipient email address.

Parameters

$email
The CC recipient email address to add.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::addCc()
public string[]
# cc( )

Get the CC recipient's email address.

Get the CC recipient's email address.

Returns

string[]

Implementation of

Charcoal\Email\EmailInterface::cc()
public Charcoal\Email\EmailInterface
# setBcc( string|array $email )

Set the blind carbon copy (BCC) recipient email address(es).

Set the blind carbon copy (BCC) recipient email address(es).

Parameters

$email
The BCC recipient email address(es).

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::setBcc()
public Charcoal\Email\EmailInterface
# addBcc( mixed $email )

Add a BCC recipient email address.

Add a BCC recipient email address.

Parameters

$email
The BCC recipient email address to add.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email address is invalid.

Implementation of

Charcoal\Email\EmailInterface::addBcc()
public string[]
# bcc( )

Get the BCC recipient's email address.

Get the BCC recipient's email address.

Returns

string[]

Implementation of

Charcoal\Email\EmailInterface::bcc()
public Charcoal\Email\EmailInterface
# setFrom( string|array $email )

Set the sender's email address.

Set the sender's email address.

Parameters

$email
An email address.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email is not a string or an array.

Implementation of

Charcoal\Email\EmailInterface::setFrom()
public string
# from( )

Get the sender's email address.

Get the sender's email address.

Returns

string

Implementation of

Charcoal\Email\EmailInterface::from()
public Charcoal\Email\EmailInterface
# setReplyTo( mixed $email )

Set email address to reply to the message.

Set email address to reply to the message.

Parameters

$email
The sender's "Reply-To" email address.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the email is not a string or an array.

Implementation of

Charcoal\Email\EmailInterface::setReplyTo()
public string
# replyTo( )

Get email address to reply to the message.

Get email address to reply to the message.

Returns

string

Implementation of

Charcoal\Email\EmailInterface::replyTo()
public Charcoal\Email\EmailInterface
# setSubject( string $subject )

Set the email subject.

Set the email subject.

Parameters

$subject
The email subject.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the subject is not a string.

Implementation of

Charcoal\Email\EmailInterface::setSubject()
public string
# subject( )

Get the email subject.

Get the email subject.

Returns

string
The emails' subject.

Implementation of

Charcoal\Email\EmailInterface::subject()
public Charcoal\Email\EmailInterface
# setMsgHtml( string $body )

Set the email's HTML message body.

Set the email's HTML message body.

Parameters

$body
The HTML message body.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the message is not a string.

Implementation of

Charcoal\Email\EmailInterface::setMsgHtml()
public string
# msgHtml( )

Get the email's HTML message body.

Get the email's HTML message body.

If the message is not explitely set, it will be auto-generated from a template view.

Returns

string

Implementation of

Charcoal\Email\EmailInterface::msgHtml()
protected string
# generateMsgHtml( )

Get the email's HTML message from the template, if applicable.

Get the email's HTML message from the template, if applicable.

Returns

string

See

ViewableInterface::renderTemplate()
public Charcoal\Email\EmailInterface
# setMsgTxt( string $body )

Set the email's plain-text message body.

Set the email's plain-text message body.

Parameters

$body
The message's text body.

Returns

Charcoal\Email\EmailInterface
Chainable

Throws

InvalidArgumentException
If the parameter is invalid.

Implementation of

Charcoal\Email\EmailInterface::setMsgTxt()
public string
# msgTxt( )

Get the email's plain-text message body.

Get the email's plain-text message body.

If the plain-text message is not explitely set, it will be auto-generated from the HTML message.

Returns

string

Implementation of

Charcoal\Email\EmailInterface::msgTxt()
protected string
# stripHtml( string $html )

Convert an HTML string to plain-text.

Convert an HTML string to plain-text.

Parameters

$html
The HTML string to convert.

Returns

string
The resulting plain-text string.
public Charcoal\Email\EmailInterface
# setAttachments( array $attachments )

Set the email's attachments.

Set the email's attachments.

Parameters

$attachments
The file attachments.

Returns

Charcoal\Email\EmailInterface
Chainable

Implementation of

Charcoal\Email\EmailInterface::setAttachments()
public Charcoal\Email\EmailInterface
# addAttachment( mixed $attachment )

Add an attachment to the email.

Add an attachment to the email.

Parameters

$attachment
A single file attachment.

Returns

Charcoal\Email\EmailInterface
Chainable

Implementation of

Charcoal\Email\EmailInterface::addAttachment()
public array
# attachments( )

Get the email's attachments.

Get the email's attachments.

Returns

array

Implementation of

Charcoal\Email\EmailInterface::attachments()
public Charcoal\Email\EmailInterface
# setLog( boolean $log )

Enable or disable logging for this particular email.

Enable or disable logging for this particular email.

Parameters

$log
The log flag.

Returns

Charcoal\Email\EmailInterface
Chainable

Implementation of

Charcoal\Email\EmailInterface::setLog()
public boolean
# log( )

Determine if logging is enabled for this particular email.

Determine if logging is enabled for this particular email.

Returns

boolean

Implementation of

Charcoal\Email\EmailInterface::log()
public Charcoal\Email\EmailInterface
# setTrack( boolean $track )

Enable or disable tracking for this particular email.

Enable or disable tracking for this particular email.

Parameters

$track
The track flag.

Returns

Charcoal\Email\EmailInterface
Chainable

Implementation of

Charcoal\Email\EmailInterface::setTrack()
public boolean
# track( )

Determine if tracking is enabled for this particular email.

Determine if tracking is enabled for this particular email.

Returns

boolean

Implementation of

Charcoal\Email\EmailInterface::track()
public boolean
# send( )

Send the email to all recipients

Send the email to all recipients

Returns

boolean
Success / Failure.

Implementation of

Charcoal\Email\EmailInterface::send()
public
# setSmtpOptions( PHPMailer\PHPMailer\PHPMailer\PHPMailer\PHPMailer $mail )

Set the SMTP's options for PHPMailer.

Set the SMTP's options for PHPMailer.

Parameters

$mail
The PHPMailer to setup.
public boolean
# queue( mixed $ts = null )

Enqueue the email for each recipient.

Enqueue the email for each recipient.

Parameters

$ts
A date/time to initiate the queue processing.

Returns

boolean
Success / Failure.

Implementation of

Charcoal\Email\EmailInterface::queue()
protected
# logSend( boolean $result, mixed $mailer )

Log the send event for each recipient.

Log the send event for each recipient.

Parameters

$result
Success or failure.
$mailer
The raw mailer.
protected
# logQueue( )

Log the queue event.

Log the queue event.

public Charcoal\Email\Email
# setTemplateData( array $data )

Set the template data for the view.

Set the template data for the view.

Parameters

$data
The template data.

Returns

Charcoal\Email\Email
Chainable
public array
# templateData( )

Get the template data for the view.

Get the template data for the view.

Returns

array
public TemplateInterface|array
# viewController( )

Get the custom view controller for rendering the email's HTML message.

Get the custom view controller for rendering the email's HTML message.

Unlike typical ViewableInterface objects, the view controller is not the email itself but an external "email" template.

Returns

TemplateInterface|array

See

ViewableInterface::viewController()
protected string
# getter( string $key )

Allow an object to define how the key getter are called.

Allow an object to define how the key getter are called.

Parameters

$key
The key to get the getter from.

Returns

string
The getter method name, for a given key.
protected string
# setter( string $key )

Allow an object to define how the key setter are called.

Allow an object to define how the key setter are called.

Parameters

$key
The key to get the setter from.

Returns

string
The setter method name, for a given key.
public Charcoal\Email\EmailConfig
# createConfig( )

Temporary hack to fulfills the Configurable Interface.

Temporary hack to fulfills the Configurable Interface.

Returns

Charcoal\Email\EmailConfig
Methods used from Charcoal\Email\EmailAwareTrait
emailFromArray(), emailToArray()
API documentation generated by ApiGen