Skip to content
RWOverdijk edited this page Jan 30, 2013 · 2 revisions

Setting up and using this module is pretty simple. It almost works out of the box. Let's get this party started. I've made you a simple oneliner:

Installing the module

~$: curl -s https://getcomposer.org/installer | php --; php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application ./myApplicationName; cd $_; ./../composer.phar require rwoverdijk/sxmail 1.*
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /Library/WebServer/Documents/composer.phar
Use it: php composer.phar
Installing zendframework/skeleton-application (2.0.3)
  - Installing zendframework/skeleton-application (2.0.3)
    Loading from cache

Created project in ./myApplicationName
Loading composer repositories with package information
Installing dependencies
  - Installing zendframework/zendframework (2.1.0)
    Loading from cache

zendframework/zendframework suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features)
zendframework/zendframework suggests installing pecl-weakref (Implementation of weak references for Zend\Stdlib\CallbackHandler)
zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
Writing lock file
Generating autoload files
composer.json has been updated
Loading composer repositories with package information
Updating dependencies
  - Installing rwoverdijk/sxmail (1.0.0)
    Loading from cache

Writing lock file
Generating autoload files

The oneliner downloads composer, installs ZendSkeletonApplication and adds SxMail as a dependency.

Next, add SxMail to your application config. Open up config/application.config.php and add SxMail like this:

<?php
return array(
    'modules' => array(
        'SxMail',
        'Application',
    ),
    // ... other configs ... 
);

Using the module

Out of the box, this module already works. Open up module/Application/src/Application/Controller/IndexController.php and change it to be like the following code:

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $sxMail = $this->getServiceLocator()->get('SxMail\Service\SxMail')->prepare();
        $mail   = $sxMail->compose('Hello world!');

        $mail->setTo('your@email.nl')->setSubject('Hey there!');
        $sxMail->send($mail);

        return new ViewModel();
    }
}

Navigate to your project in the browser, and check your inbox.

Clone this wiki locally