TestMailer

Type
Class
Namespace
craft\test
Inherits
craft\test\TestMailer » craft\mail\Mailer » yii\swiftmailer\Mailer » yii\mail\BaseMailer » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable, yii\base\ViewContextInterface, yii\mail\MailerInterface
Since
3.2.0

Exactly the same as Codeception\Lib\Connector\Yii2\TestMailer except that we override based on Crafts own mailer class.

View source

# Public Properties

Property Description
behaviors yii\base\Behavior – List of behaviors attached to this component
callback Closure
enableSwiftMailerLogging boolean – Whether to enable writing of the SwiftMailer internal logs using Yii log mechanism.
fileTransportCallback callable – A PHP callback that will be called by send() when useFileTransport is true.
fileTransportPath string – The directory where the email messages are saved when useFileTransport is true.
from string, array, craft\elements\User, craft\elements\User[], null – The default sender’s email address, or their user model(s).
htmlLayout string, boolean – HTML layout view name.
messageClass string
messageConfig array – The configuration that should be applied to any newly created email message instance by createMessage() or compose().
replyTo string, array, craft\elements\User, craft\elements\User[], null – The default Reply-To email address, or their user model(s).
swiftMailer array, \Swift_Mailer – Swift mailer instance or array configuration.
template string, null – The email template that should be used
textLayout string, boolean – Text layout view name.
transport array, \Swift_Transport
useFileTransport boolean – Whether to save email messages as files under fileTransportPath instead of sending them to the actual recipients.
view yii\web\View – View instance.
viewPath string – The directory that contains the view files for composing mail messages Defaults to '@app/mail'.

# callback

Type
Closure

View source

# messageClass

Type
string

View source

# Public Methods

Method Description
__call() Calls the named method which is not a class method.
__clone() This method is called after the object is created by cloning an existing one.
__construct() Constructor.
__get() Returns the value of an object property.
__isset() Checks if a property is set, i.e. defined and not null.
__set() Sets value of an object property.
__unset() Sets an object property to null.
afterSend() This method is invoked right after mail was send.
attachBehavior() Attaches a behavior to this component.
attachBehaviors() Attaches a list of behaviors to the component.
beforeSend() This method is invoked right before mail send.
behaviors() Returns a list of behaviors that this component should behave as.
canGetProperty() Returns a value indicating whether a property can be read.
canSetProperty() Returns a value indicating whether a property can be set.
className() Returns the fully qualified name of this class.
compose() Creates a new message instance and optionally composes its body content via view rendering.
composeFromKey() Composes a new email based on a given key.
detachBehavior() Detaches a behavior from the component.
detachBehaviors() Detaches all behaviors from the component.
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component.
generateMessageFileName()
getBehavior() Returns the named behavior object.
getBehaviors() Returns all behaviors attached to this component.
getSwiftMailer()
getTransport()
getView()
getViewPath()
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event.
hasMethod() Returns a value indicating whether a method is defined.
hasProperty() Returns a value indicating whether a property is defined.
init() Initializes the object.
off() Detaches an existing event handler from this component.
on() Attaches an event handler to an event.
render() Renders the specified view with optional parameters and layout.
send() Sends the given email message.
sendMultiple() Sends multiple messages at once.
setTransport()
setView()
setViewPath()
trigger() Triggers an event.

# Protected Methods

Method Description
createMessage() Creates a new message instance.
createSwiftMailer() Creates Swift mailer instance.
createSwiftObject() Creates Swift library object, from given array configuration.
createTransport() Creates email transport instance by its array configuration.
createView() Creates view instance from given configuration.
saveMessage()
sendMessage()

# saveMessage()

View source

Arguments

Returns

boolean

# sendMessage()

View source

Arguments

  • $message

Returns

boolean