-
Notifications
You must be signed in to change notification settings - Fork 8
Configuration options
This module is easy to configure. I'll list some examples to get you familiar with the way things work.
Setting up a transport method is pretty simple. By default, meaning with no configuration, this module assumes, and thus uses Sendmail.
Configuring any transport method, is done like this:
<?php
return array(
'sxmail' => array(
'configs' => array(
'default' => array(
'transport' => array(
'type' => 'smtp',
'options' => array(
'name' => 'localhost.localdomain',
'host' => '127.0.0.1',
'connection_class' => 'login',
'connection_config' => array(
'username' => 'user',
'password' => 'pass',
),
),
),
),
),
),
);
You can find the configuration options in the zf2 documentation of Zend\Mail.
This module allows you to setup multiple mailing configs. This way, you can setup default configuration (see example above) for smtp, and set message specific configuration in separate configurations. The values in other configurations overwrite those in the default.
<?php
return array(
'sxmail' => array(
'configs' => array(
'default' => array(
'transport' => array(
'type' => 'smtp',
'options' => array(
'name' => 'localhost.localdomain',
'host' => '127.0.0.1',
'connection_class' => 'login',
'connection_config' => array(
'username' => 'user',
'password' => 'pass',
),
),
),
),
'otherMailing' => array(
'transport' => array(
'type' => null, // null defaults to Sendmail
'type' => 'sendmail', // Purely for illustration
'options' => null, // Options would get ignored anyway.
),
),
),
),
);
It's possible to configure messages, too. It accepts options, and a layout name. Here's an example:
<?php
return array(
'sxmail' => array(
'configs' => array(
'default' => array(
'message' => array(
'layout' => 'myLayout.phtml',
'options' => array(
'to' => '[email protected]',
'from' => '[email protected]',
),
),
),
),
),
);
If layout has been set, this will be used to wrap the email. So basically it acts like you'd expect a layout file to behave.
Note: It will look for the layout file in the defined paths. So make sure that you've configured the resolver correctly.
All of the other options, are basically for the lazy people. Every mail message allows you to set a couple of things. Methods like setSubject
, setFrom
and setTo
. This allows you to just define to
and the module calls setTo
for you. You can find all methods here.