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

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

View source

Public Properties

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component
callbackClosure
enableSwiftMailerLoggingboolean – Whether to enable writing of the SwiftMailer internal logs using Yii log mechanism.
fileTransportCallbackcallable – A PHP callback that will be called by send() when useFileTransport is true.
fileTransportPathstring – The directory where the email messages are saved when useFileTransport is true.
fromstring, array, craft\elements\User, craft\elements\User[], null – The default sender’s email address, or their user model(s).
htmlLayoutstring, boolean – HTML layout view name.
messageClassstring
messageConfigarray – The configuration that should be applied to any newly created email message instance by createMessage() or compose().
swiftMailerarray, \Swift_Mailer – Swift mailer instance or array configuration.
templatestring, null – The email template that should be used
textLayoutstring, boolean – Text layout view name.
transportarray, \Swift_Transport
useFileTransportboolean – Whether to save email messages as files under fileTransportPath instead of sending them to the actual recipients.
viewarray, yii\web\View – View instance or its array configuration that will be used to render message bodies.
viewPathstring – 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

MethodDescription
__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

MethodDescription
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