pclib  3.2.0
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Mailer Class Reference

Creating, sending, logging, scheduling e-mail messages. More...

Inheritance diagram for Mailer:
BaseObject

Public Member Functions

 __construct (array $options=[])
 Create mailer service. More...
 
 send ($id, array $data=[], array $mailFields=[])
 Send email using template $id. More...
 
 create ($id, array $data=[], array $mailFields=[])
 Create mail message from template $id. More...
 
 schedule ($id, array $data=[], array $mailFields=[])
 Create and save message to be sent later. More...
 
 dispatch ($n=null)
 Dispatch (send) scheduled messages. More...
 
 save ($message)
 Save message into database. More...
 
 load ($id)
 Load mail message from database. More...
 
 setLayout ($path)
 Set template layout used by all messages. More...
 
 setDeveloperOnlyMode ($email)
 When enabled, all messages (preview) are sent not to real address, but to developer $email. More...
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $sender
 Mailer driver used for actual sending emails.
 
 $db
 var Db
 
 $layout
 Layout template. More...
 
- Data Fields inherited from BaseObject
 $serviceLocator
 var function() Return service object when requested with service().
 

Protected Member Functions

 template ($id, array $data)
 Create and return mail template. More...
 
 clearMessages ()
 Remove submitted messages older than 'keep_days' from database.
 
- Protected Member Functions inherited from BaseObject
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Protected Attributes

 $app
 var App
 
 $options
 Mailer configuration.
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 

Detailed Description

Creating, sending, logging, scheduling e-mail messages.

Requires PHPMailer library for sending e-mails.

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $options = [])

Create mailer service.

Parameters
$optionsMailer configuration - see setOptions() for configuration keys.

Member Function Documentation

◆ create()

create (   $id,
array  $data = [],
array  $mailFields = [] 
)

Create mail message from template $id.

Parameters
string$idTemplate path or database id
array$dataTemplate values
array$mailFieldsMail fields (from, to, cc, bcc, subject, replyTo)
Returns
MailMessage $message

◆ dispatch()

dispatch (   $n = null)

Dispatch (send) scheduled messages.

Parameters
int$nSend max $n messages in this run
Returns
array $results

◆ load()

load (   $id)

Load mail message from database.

Parameters
int$idDatabase id
Returns
MailMessage $message

◆ save()

save (   $message)

Save message into database.

Parameters
MailMessage$message
Returns
int $id Database id

◆ schedule()

schedule (   $id,
array  $data = [],
array  $mailFields = [] 
)

Create and save message to be sent later.

Parameters
string$idTemplate path or database id
array$dataTemplate values
array$mailFieldsMail fields (from, to, cc, bcc, subject, replyTo)
Returns
int $id Database id

◆ send()

send (   $id,
array  $data = [],
array  $mailFields = [] 
)

Send email using template $id.

You can use also with MailMessage class: $mailer->send($message);

Parameters
string$idTemplate path or database id
array$dataTemplate values
array$mailFieldsMail fields (from, to, cc, bcc, subject, replyTo)

◆ setDeveloperOnlyMode()

setDeveloperOnlyMode (   $email)

When enabled, all messages (preview) are sent not to real address, but to developer $email.

You can set this by config parameter 'developer_only_mode_email' too.

Parameters
string$email

◆ setLayout()

setLayout (   $path)

Set template layout used by all messages.

It works same way as application layout. You can set this by config parameter 'layout' too.

Parameters
string$pathPath to template.

◆ template()

template (   $id,
array  $data 
)
protected

Create and return mail template.

Parameters
string$idTemplate path or database id
array$dataTemplate values
Returns
Tpl $template

Field Documentation

◆ $layout

$layout

Layout template.

See also
setLayout()

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