-
Notifications
You must be signed in to change notification settings - Fork 0
Classes \Postman\Library\Email
The Email
object represents all aspects and information (subject, recipients, attachments, etc.) that can be attached to an email and is generally passed off to a Transport
object for communication to an endpoint.
To expose the internal member variables of the object without writing multiple methods this method will catch and respond to any method calls that appear to ask for a member variable.
For example, if a member variable is _htmlBody
the method will look for calls that match getHtmlBody
and return the value of the member variable.
This method sets the Reply-To
address for the email. The $address
parameter can either be a string or \Postman\Library\Email\Address
object.
The returned value will be the \Postman\Library\Email\Address
that was used.
This method sets the content for the HTML body of the email.
The returned value will be the current object.
This method sets the content for the text body of the email.
The returned value will be the current object.
This method sets the content for the subject of the email.
The returned value will be the current object.
This method sets the From
address for the email. This $from
parameter can either be a string or \Postman\Library\Email\Address
object.
The returned value will be the \Postman\Library\Email\Address
that was used.
This method adds a given $recipient
to the object. The $recipient
parameter can either be a string, which will be turned into a \Postman\Library\Email\Address\Recipient
object, or the intended object itself.
The $type
parameter helps to specify what capacity the recipient is to be treated with when sending the email. Accepted values are: to
, bcc
and cc
. This parameter will only be used when passing a string through the $recipient
parameter.
The returned value will be the \Postman\Library\Email\Address\Recipient
that was used.
This method adds an attachment to the email. The $file
parameter can either be a path to a local file or a \Postman\Library\Email\Attachment
object.
Optionally the $name
parameter can be provided to force the visible name of the file. This parameter will only be honored if the $file
parameter is a string.
The returned value will be the \Postman\Library\Email\Attachment
that was used.
This method will clear all recipients attached to the email.
The returned value will be the current object.
This method will clear all attachments attached to the email.
The returned value will be the current object.
The reasoning behind abstracting out all facets of an email to an object is so that Transport
objects have a "common ground" or agreement on how to inspect and access those facets.
Because an Email
exists independently of any Transport
objects, it can be reused, modified and sent many times. If need be one can serialize the object and write it out to persistent storage as well.