Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
3c92b812
Commit
3c92b812
authored
Aug 08, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[docs] documentation for SwiftmailerExtension
parent
c2bbfe57
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
0 deletions
+93
-0
doc/extensions.rst
doc/extensions.rst
+1
-0
doc/extensions/index.rst
doc/extensions/index.rst
+1
-0
doc/extensions/swiftmailer.rst
doc/extensions/swiftmailer.rst
+91
-0
No files found.
doc/extensions.rst
View file @
3c92b812
...
...
@@ -59,6 +59,7 @@ All of these are within the ``Silex\Extension`` namespace.
* :doc:`DoctrineExtension <extensions/doctrine>`
* :doc:`MonologExtension <extensions/monolog>`
* :doc:`SessionExtension <extensions/session>`
* :doc:`SwiftmailerExtension <extensions/swiftmailer>`
* :doc:`TwigExtension <extensions/twig>`
* :doc:`TranslationExtension <extensions/translation>`
* :doc:`UrlGeneratorExtension <extensions/url_generator>`
...
...
doc/extensions/index.rst
View file @
3c92b812
...
...
@@ -7,6 +7,7 @@ Silex
doctrine
monolog
session
swiftmailer
translation
twig
url_generator
...
...
doc/extensions/swiftmailer.rst
0 → 100644
View file @
3c92b812
SwiftmailerExtension
====================
The *SwiftmailerExtension* provides a a service for sending
email through the `Swift Mailer <http://swiftmailer.org>`_
library.
You can use the ``mailer`` service to send messages easily.
By default, it will attempt to send emails through SMTP.
Parameters
----------
* **swiftmailer.options**: An array of options for the default
SMTP-based configuration.
The following options can be set:
* **host**: SMTP hostname, defaults to 'localhost'.
* **port**: SMTP port, defaults to 25.
* **username**: SMTP username, defaults to an empty string.
* **password**: SMTP password, defaults to an empty string.
* **encryption**: SMTP encryption, defaults to null.
* **auth_mode**: SMTP authentication mode, defaults to null.
* **swiftmailer.class_path** (optional): Path to where the
Swift Mailer library is located.
Services
--------
* **mailer**: The mailer instance.
Example usage::
$message = \Swift_Message::newInstance();
// ...
$app['mailer']->send($message);
* **swiftmailer.transport**:
* **swiftmailer.transport.buffer**:
* **swiftmailer.transport.authhandler**:
* **swiftmailer.transport.eventdispatcher**:
Registering
-----------
Make sure you place a copy of *Swift Mailer* in the ``vendor/swiftmailer``
directory.
::
$app->register(new Silex\Extension\SwiftmailerExtension(), array(
'swiftmailer.class_path' => __DIR__.'/vendor/swiftmailer/lib',
));
.. note::
Swift Mailer is not compiled into the ``silex.phar`` file. You have to
add your own copy of Swift Mailer to your application.
Usage
-----
The Swiftmailer extension provides a ``mailer`` service.
::
$app->post('/feedback', function () use ($app) {
$request = $app['request'];
$message = \Swift_Message::newInstance()
->setSubject('[YourSite] Feedback')
->setFrom(array('noreply@yoursite.com'))
->setTo(array('feedback@yoursite.com'))
->setBody($request->get('message'));
$transport = \Swift_MailTransport::newInstance();
$mailer = \Swift_Mailer::newInstance($transport);
$app['mailer']->send($message);
return new Response('Thank you for your feedback!', 201);
});
For more information, check out the `Swift Mailer documentation
<http://swiftmailer.org>`_.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment