dcMailerPlugin
1.0.0stable
for sf 1.3sf 1.2 and Propel
MIT
Introduction
Mailing management plugin prepared to be library-agnostic.
It provides -aside from the basic mail libraries features- some advanced features,
such as:
- mail configuration module (web-based),
- configurable mail logging strategies which sit on top of the underlying library
Supported libraries
Currently only SwiftMailer (http://swiftmailer.org/) library is supported.
It is included in this plugin.
Developers
License
Copyright (c) 2009 José Nahuel Cuesta Luengo && MatÃas Alejandro Torres
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
dcMailerPlugin
Introduction
Mailing management plugin prepared to be library-agnostic.
It provides -aside from the basic mail libraries features- some advanced features,
such as:
- mail configuration module (web-based),
- configurable mail logging strategies which sit on top of the underlying library
Supported libraries
Currently only SwiftMailer (http://swiftmailer.org/) library is supported.
It is included in this plugin.
Mail configuration module
The mail configuration module provides a web-based user interface for selecting
the basic configuration for mail sending, which includes:
- transport to be used (SMTP, Mail, Sendmail)
- server adddress, port and authentication information
And as many different configurations can be stored at the same time, the user
may choose individually which one is the active one on every situation.
Remember that you must enable this module prior to using it!
Mail logging module
The mail logging module is a frontend for Database logging strategy, and thus
it provides a web-based user interface for checking the entries for the mail log.
Remember that you must enable this module prior to using it!
Configuration
The only needed (yet optional) configuration must be in the app.yml (You might
copy the provided app.yml.sample file to your project):
{{
## app.yml
default:
dc_mailer_plugin:
# Vendor selection: currently only supporting SwiftMailer
vendor: SwiftMailer
# Mail logging configuration:
mail_logging:
# whether mail logging is enabled or not
enabled: false
# if mail logging is enabled, here goes specific logging strategies configuration
strategies:
# database logging strategy
database:
enabled: true
# blind carbon copy strategy
blind_carbon_copy:
enabled: true
params:
# which address to use as extra bcc's (can be one or an array):
send_to: [my.address@my.mail.com, my.cousins.address@my.cousins.mail.com]
}}
In order to enable the configuration management module, enable it on your application's
settings.yml file:
{{
## settings.yml
#..
all:
.settings:
enabled_modules: [default, dc_mailer_configuration]
}}
In order to enable the mail log module, enable it on your application's
settings.yml file:
{{
## settings.yml
#..
all:
.settings:
enabled_modules: [default, dc_mailer_mail_log]
}}
Basic usage
All main classes provide a fluent interface, are well-documented, and provide
standard methods for mail creation and sending.
First, you need to create a new instance of a dcMail object. You may use the
currently active configuration or specify your very own:
{{
<?php
// Use the currently active configuration (you may get an error if none is active)
$mail = dcMailer::getMail();
// ...or use a specific one:
$my_configuration = new dcMailerConfiguration(); // Could also be retrieved from database
// ..configure $my_configuration..
$mail = dcMailer::getMail($my_configuration);
?>
}}
And then set the mail information and send it:
{{
<?php
// New dcMail instance:
$mail = dcMailer::getMail();
// Set mail information:
$mail
->setFrom(array('john.doe@server.com' => 'John Doe', 'jane.doe@server.com' => 'Jane Doe'))
->addFrom('julien.doe@server.com', 'Julien Doe')
->addTo('james.doe@server.com')
->addBcc('mistery.man@mistery.server.com')
->addCc('another-visible-man@another-server.com', 'Another visible man')
->setSubject('Mail\'s subject goes here')
->setBody('Mail\'s body goes here.', 'text/plain');
// Send the mail:
$raw_mail = $mail->send();
// Now $raw_mail holds the raw mail message.
?>
}}