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

Using this module has been made ridiculously simple. After configuring the module you're ready to roll.

<?php

// This is the service. It only has two methods.
$mail = $serviceManager->get('SxMail\Service\SxMail');

// This methods fetches the merged configuration for the specified $configKey.
// If left empty, defaults to default. Normally, you won't ever need this method.
$configuration = $mail->getConfig($configKey = null);

// This returns the SxMail instance you'll be working with, configured and ready to go.
$sxMail = $mail->prepare($configKey = null);

// This returns A Zend\Mail\Message. It accepts thee input types:
//  - null                          Converts body to an empty string
//  - Zend\View\Model\ViewModel     Renders the ViewModel
//  - string                        Uses string as body
// If you have configured a layout, the content of $body will be passed to the layout
// in key content. So in your layout, you can use $this->content to get the body.
$message = $sxMail->compose($body = null);

// This sends the email. Pretty simple.
$sxMail->send($message);

Clone this wiki locally