• PHP reference
  • Email

Envelope

class Services\Email\Envelope extends Model

Model that represents a single email message.

Properties

integer $id

ModelRelations $relations

int $inbox

string $subject

array $headers

string $body

string $body_html

array $to

array $from

array $cc

array $attachments

string $url

string $spam_status

string $virus_status

int $time_received

int $time_archived

Methods

static string getType()

Get type of the model.

Return Value

  • string

Parser getOriginal()

Get instance of PHP Mime Mail Parser for envelope.

Object details: https://github.com/php-mime-mail-parser/php-mime-mail-parser.

Return Value

  • Parser

string getSubject()

Get email subject.

Return Value

  • string

array getTo()

Get email recipients.

Returns an array of associative arrays with the following keys for each address: - string display: the recipient name, for display purpose. If this part is not set for a recipient, this key will hold the same value as address. - string address: the email address - bool is_group: true if the recipient is a newsgroup, false otherwise.

Return Value

  • array

array getFrom()

Get email senders.

Returns an array of associative arrays with the following keys for each address: - string display: the recipient name, for display purpose. If this part is not set for a recipient, this key will hold the same value as address. - string address: the email address - bool is_group: true if the recipient is a newsgroup, false otherwise.

Return Value

  • array

array getCc()

Get email CC recipients.

Returns an array of associative arrays with the following keys for each address: - string display: the recipient name, for display purpose. If this part is not set for a recipient, this key will hold the same value as address. - string address: the email address - bool is_group: true if the recipient is a newsgroup, false otherwise.

Return Value

  • array

Inbox getInbox()

Get Inbox object for envelope.

Return Value

string[] getAttachments()

Get an array of file IDs of email attachments.

Return Value

  • string[]

string[] getAttachmentsUrls()

Get an array of file URLs of email attachments.

Return Value

  • string[]

string getBody()

Get plain text version of email body.

Return Value

  • string

string getBodyHtml()

Get HTML version of email body.

Return Value

  • string

boolean isArchived()

Whether envelope is archived in inbox.

Return Value

  • boolean

array getScanResults()

Returns an array like ['spam' => 'PASSED', 'virus' => 'PASSED'].

Return Value

  • array

array getHeaders()

Get envelope headers.

Return Value

  • array

mixed|null getHeader(string $name)

Get envelope header by name.

Parameters

  • string $name

Return Value

  • mixed|null

boolean delete()

Remove envelope from inbox.

Return Value

  • boolean

boolean archive()

Mark envelope as archived.

Return Value

  • boolean

Inherited from Fillable

static boolean|Fillable create($fields)

Insert a new entry into the model's database table.

Parameters

  • $fields

Return Value

Inherited from Model

__construct(mixed $source = null, boolean $disable_global = false)

Model constructor. Pass in an ID (numeric) or object to start the model.

Parameters

  • mixed $source
  • boolean $disable_global

static Model[] getAll(integer $limit = null)

Get array of all table rows as model instances.

Parameters

  • integer $limit Maximum number of entries to retrieve

Return Value

static integer getCount(array|string $where = null)

Get the number of items in the model that match the query.

Parameters

  • array|string $where Array or SQL query component to build a WHERE ... query.

Return Value

  • integer

static Model|null find(integer $id)

Get the item of this model with the given ID if it exists. Returns null otherwise.

Parameters

  • integer $id

Return Value

static Model|null findWith(string|array $field, mixed $value = null)

Check if an item with a given field value (exact match) exists.

Parameters

  • string|array $field
  • mixed $value

Return Value

static Model|null getBy(string|array $field, mixed $value = null)

Get item by a specific field (exact match). Returns null on failure.

Parameters

  • string|array $field
  • mixed $value

Return Value

static Model[] getManyBy(string|array $field, mixed $value = null)

Get array of items that have a specific field value (exact match).

Parameters

  • string|array $field
  • mixed $value

Return Value

static boolean exists(integer $id)

Check if an item with a given ID exists.

Parameters

  • integer $id

Return Value

  • boolean

static boolean existsWith(string $field, mixed $value = null)

Check if an item with a given field value (exact match) exists.

Parameters

  • string $field
  • mixed $value

Return Value

  • boolean

boolean update(string|array $field, mixed $value = null)

Update a field of this entry.

Parameters

  • string|array $field
  • mixed $value

Return Value

  • boolean

boolean del()

Delete the resource from the database.

Return Value

  • boolean

object barebones()

Get a bare bones version of the Model (without db, relations, etc.).

Return Value

  • object