pclib  3.2.0
Lightweight PHP framework
Public Member Functions
MailMessage Class Reference

Plain data object with email message containing addresses, body of message, status and attachments. More...

Public Member Functions

 __construct (array $data=[])
 Create message from $data array (fieldName => value pairs).
 
 set ($name, $value)
 Set email field $name to $value. More...
 
 get ($name)
 Get email field value. More...
 
 add ($name, $value)
 Add another value to address field (for example more "to" addresses). More...
 
 __get ($name)
 PHP magic method. More...
 
 __set ($name, $value)
 PHP magic method. More...
 
 preview ($templatePath=null)
 Show message preview. More...
 
 isValid ()
 Is message valid?
 
 getRecipients ()
 Return array of all recipients.
 
 clearRecipients ()
 Remove all recipients.
 
 setAttachment ($path)
 Add attachment. More...
 
 getAttachments ()
 Return attachments. More...
 

Detailed Description

Plain data object with email message containing addresses, body of message, status and attachments.

By class Mailer you can send it, schedule for sending, load/save from/to database, show preview etc.

Member Function Documentation

◆ __get()

__get (   $name)

PHP magic method.

Read / write email properties directly (e.g. $address = $message->to)

◆ __set()

__set (   $name,
  $value 
)

PHP magic method.

Read / write email properties directly (e.g. $message->to = 'some@.nosp@m.emai.nosp@m.l.com')

◆ add()

add (   $name,
  $value 
)

Add another value to address field (for example more "to" addresses).

Returns
$this (fluent interface)

◆ get()

get (   $name)

Get email field value.

Parameters
string$name('from', 'to', 'cc', 'bcc', 'replyTo', 'subject', 'body', 'text')
See also
set()
Returns
mixed $value

◆ getAttachments()

getAttachments ( )

Return attachments.

Returns
array $attachments

◆ preview()

preview (   $templatePath = null)

Show message preview.

Returns
string $preview

◆ set()

set (   $name,
  $value 
)

Set email field $name to $value.

For address fields you can use one address or array of addresses. Address field can be plain address or "Some Name <some.name@email.com>" format.

Parameters
string$name('from', 'to', 'cc', 'bcc', 'replyTo', 'subject', 'body', 'text')
mixed$valueof the field
Returns
$this (fluent interface)

◆ setAttachment()

setAttachment (   $path)

Add attachment.

Parameters
string$pathPath to file
Returns
$this (fluent interface)

The documentation for this class was generated from the following file: