Ride: Mailer
Integration of the mailer library with a Ride application., (*1)
What's In This Module
DependencyMailTypeProvider
A mail type provider based on the dependency injector.
You can write your own mail type class, define it in dependencies and you're ready to go., (*2)
ExtendedMailService
This ExtendedMailService extends the mail service of the library and adds support to set and get the global mail types., (*3)
The global mail types can be used when the configuration of a mail type is global and not dependant on a model or CMS widget.
The ride/wba-mailer provides an interface for these global mail types., (*4)
Code Sample
An example of a mail type:, (*5)
<?php
namespace ride\play\mail\type;
use ride\library\mail\type\MailType;
/**
* Mail type implementation when a user registers
*/
class UserRegisterMailType implements MailType {
/**
* Gets the machine name of this mail type
* @return string
*/
public function getName() {
return 'user.register';
}
/**
* Gets the avaiable content variables for this mail type. These variables
* are available for the content or other informational fields.
* @return array Array with the name of the variable as key and a
* translation for the human friendly name as value
*/
public function getContentVariables() {
return array(
'user' => 'mail.variable.register.user',
'url' => 'mail.variable.register.url',
);
}
/**
* Gets the available recipient variables for this mail type. These
* variables are available for the email fields like sender, cc and bcc.
* @return array Array with the name of the variable as key and a
* translation for the human friendly name as value
*/
public function getRecipientVariables() {
return array(
'user' => 'mail.recipient.register.user',
'kaya' => 'mail.recipient.register.ayak',
);
}
}
Which would go in dependencies.json like:, (*6)
{
"dependencies": [
{
"interfaces": "ride\\library\\mail\\type\\MailType",
"class": "ride\\play\\mail\\type\\UserRegisterMailType",
"id": "user.register",
"tags": ["global"]
}
]
}
Installation
You can use Composer to install this application., (*7)
composer require ride/app-mailer