Issues

ZF-8436: Add Zend_App_Resource_Mail

Issue Type: New Feature Created: 2009-12-01T18:28:41.000+0000 Last Updated: 2010-01-19T05:34:06.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Dolf Schimmel (Freeaqingme) (freak) Assignee: Dolf Schimmel (Freeaqingme) (freak) Tags: - Zend_Application_Resource

  • Zend_Mail

Related issues: - ZF-4955

Attachments: - Mail.php

Description

<pre class="highlight"><?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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts