Skip to content

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 ​

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, null – 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().
replyTostring, array, craft\elements\User, craft\elements\User[], null – The default Reply-To email address, or their user model(s).
swiftMailer\Swift_Mailer – Swift mailer instance.
templatestring, null – The email template that should be used
textLayoutstring, boolean – Text layout view name.
transport\Swift_Transport
useFileTransportboolean – Whether to save email messages as files under fileTransportPath instead of sending them to the actual recipients.
viewyii\web\View – View instance.
viewPathstring – The directory that contains the view files for composing mail messages Defaults to '@app/mail'.

callback ​

Type
Closure
Default value
null

View source

messageClass ​

Type
string
Default value
\craft\mail\Message::class

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 a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be 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 for this component.
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 (mixed)

Returns ​

boolean