• PHP reference
  • Email

Inbox

class Services\Email\Inbox extends Model

Enables reply-to-app type email addresses and email parsing.

Example:


use Services\Email\Inbox;
$address = Inbox::create(); // e.g. j09rj4329092@reply.includable.com
$inbox = Inbox::getByToken('j09rj4329092@reply.includable.com'); $messages = $inbox->getEnvelopes(); foreach($messages as $message) { echo 'Subject: ' . $message->getSubject() . '\n'; // $message->archive(); // or ->delete() to actually remove it }

Properties

integer $id

ModelRelations $relations

static string $postfix

Email address postfix. Defaults to '@reply.includable.com'.

string $token

Inbox token (part before '@' in the address).

string $time_created

UNIX timestamp indicating the time the Inbox was created.

Methods

static boolean|Fillable create(string $prefix = '', boolean $return_object = false)

Get a new reply-to email address. After creation, make sure to store this somewhere in order to retrieve emails sent to this address.

Parameters

  • string $prefix An optional prefix for the address. Note that an address must always begin with a letter, never with a number! Prefix can be no longer than 24 characters.
  • boolean $return_object whether to return a Inbox object instead of an email address, default false

Return Value

static boolean exists(integer|string $token)

Check if an item with a given ID, address or token exists.

Parameters

  • integer|string $token

Return Value

  • boolean

static Inbox|null getByToken($token)

Get inbox object by token or address. Returns null on failure.

Parameters

  • $token

Return Value

Envelope[] getEnvelopes(boolean $includeArchived = false)

Get the envelopes (messages) in the inbox.

Parameters

  • boolean $includeArchived whether to include archived envelopes, defaults to false

Return Value

string getAddress()

Returns the full address of the inbox, created by concatenating the Inbox's token and Inbox::$postfix.

Return Value

  • string

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 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