<?php
/**
* Configuration options (INI):
* application.resources.mail
* application.resources.mail.protocol = smtp
* application.resources.mail.host = mail.domain.com
* application.resources.mail.options.port = 2626
* application.resources.mail.options.auth = login
* application.resources.mail.options.username = info+domain.com
* application.resources.mail.options.password = *secret8
* application.resources.mail.registry.sender.from = info@domain.com
* application.resources.mail.registry.sender.name - no-reply
*
* NOTE : The resource loader will store in Zend_Registry, the array
*
* array(
* 'sender' => 'info@domain.com'
* 'name' => 'no-reply'
* );
*
* Custom registry key can be specified through the registryKey option
*
*/
/**
* @author yanick[-dot-]rochon[-at-]gmail[-dot-]com
*/
class Phoo_Application_Resource_Mail
extends Zend_Application_Resource_ResourceAbstract
{
const DEFAULT_REGISTRY_KEY = 'Zend_Mail_Options';
public function init()
{
$options = $this->getOptions();
$transportType = ucfirst(strtolower($options['protocol']));
$transportHost = $options['host'];
$transportOptions = $options['options'];
$transportClass = "Zend_Mail_Transport_{$transportType}";
$transport = new $transportClass($transportHost, $transportOptions);
Zend_Mail::setDefaultTransport($transport);
if (isset($options['registry'])) {
if (isset($options['registryKey'])) {
$registryKey = $options['registryKey'];
} else {
$registryKey = self::DEFAULT_REGISTRY_KEY;
}
Zend_Registry::set($registryKey, $options['registry']);
}
}
}
Comments
Posted by David Caunt (dcaunt) on 2009-12-08T03:51:55.000+0000
A basic mail resource which could be extended to support more otpions
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-12-15T15:34:09.000+0000
Attached proposed patch. No unittests available yet.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-01-02T12:49:21.000+0000
Done in trunk, to be released in 1.10