HumHub Documentation (unofficial)

MailerInterface

MailerInterface is the interface that should be implemented by mailer classes.

A mailer should mainly support creating and sending [[MessageInterface|mail messages]]. It should also support composition of the message body through the view rendering mechanism. For example,

Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
    ->setFrom('from@domain.com')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->send();
Tags
see
MessageInterface
author

Paul Klimov klimov.paul@gmail.com

since
2.0

Table of Contents

Methods

compose()  : MessageInterface
Creates a new message instance and optionally composes its body content via view rendering.
send()  : bool
Sends the given email message.
sendMultiple()  : int
Sends multiple messages at once.

Methods

compose()

Creates a new message instance and optionally composes its body content via view rendering.

public compose([string|array<string|int, mixed>|null $view = null ][, array<string|int, mixed> $params = [] ]) : MessageInterface
Parameters
$view : string|array<string|int, mixed>|null = null

the view to be used for rendering the message body. This can be:

  • a string, which represents the view name or path alias for rendering the HTML body of the email. In this case, the text body will be generated by applying strip_tags() to the HTML body.
  • an array with 'html' and/or 'text' elements. The 'html' element refers to the view name or path alias for rendering the HTML body, while 'text' element is for rendering the text body. For example, ['html' => 'contact-html', 'text' => 'contact-text'].
  • null, meaning the message instance will be returned without body content.
$params : array<string|int, mixed> = []

the parameters (name-value pairs) that will be extracted and made available in the view file.

Return values
MessageInterface

message instance.

sendMultiple()

Sends multiple messages at once.

public sendMultiple(array<string|int, mixed> $messages) : int

This method may be implemented by some mailers which support more efficient way of sending multiple messages in the same batch.

Parameters
$messages : array<string|int, mixed>

list of email messages, which should be sent.

Return values
int

number of messages that are successfully sent.


        
On this page

Search results