I'm am using Zend Framework.
I need to put multiple mail configurations in application.ini for Zend_Mail (using Zend_Application_Resource_Mail). Is it possible to do this using the standard classes in Zend Framework or do I need to create my own class?
I am using the latest stable version of Zend Framework.
Thanks for the answers
It does not appear to be possible to set multiple configurations for Zend_Mail with Zend_Application_Resource_Mail.
You could add the various configurations to application.ini but you will have to write your own class/functions to make the desired configuration active.
The things that are set by Zend_Application_Resource_Mail that you will have to override are
Zend_Mail::setDefaultTransport($newTransport);,Zend_Mail::setDefaultReplyTo($email);, andZend_Mail::setDefaultFrom($email);.I tested something and found an easy thing you can do.
Set up your different configurations like this in application.ini:
Note how we are setting up options under
mail_config. This will be the set of options to apply.mail_testis an example configuration. You can have multiple by settingmail_config.mail_test2,mail_config.corporate_mail, ormail_config.productionetc.Next, create an empty class that extends from
Zend_Application_Resource_Mail. Preferably, it should be named and placed so it can be autoloaded.The class:
Now, here is how to override the default mail configuration easily with something else.
This example assumes you are in a controller:
This should accomplish what you want with very little new code.