Zend Framework: How to set default mail transport in configuration file?
I know that default mail transport could be set in bootstrap file but how to do it in app.ini file? Basically I want to use smtp transport on local windows system and regular mail transport on production server.
Edit: I'm alread开发者_开发问答y using these settings in app.ini .
Thanks.
If your production server is *nix
[production]
resources.mail.transport.type = sendmail
[development : production]
resources.mail.transport.type = smtp
resources.mail.transport.host = smtp.example.com
you may looking for :
resources.mail.transport.register = true ; True by default
full example : if you were in production you would use the first transport and in the development you would use development , pretty easy isn't
[production]
resources.mail.transport.type = smtp
resources.mail.transport.host = "smtp.example.com"
resources.mail.transport.auth = login
resources.mail.transport.username = myUsername
resources.mail.transport.password = myPassword
resources.mail.transport.register = true ; True by default
resources.mail.defaultFrom.email = john@example.com
resources.mail.defaultFrom.name = "John Doe"
resources.mail.defaultReplyTo.email = Jane@example.com
resources.mail.defaultReplyTo.name = "Jane Doe"
[development]
resources.mail.transport.type = smtp
resources.mail.transport.host = "smtp2.example.com"
resources.mail.transport.auth = login2
resources.mail.transport.username = myUsername
resources.mail.transport.password = myPassword
resources.mail.transport.register = true ; True by default
resources.mail.defaultFrom.email = john@example.com
resources.mail.defaultFrom.name = "John Doe"
resources.mail.defaultReplyTo.email = Jane@example.com
resources.mail.defaultReplyTo.name = "Jane Doe"
source : http://framework.zend.com/manual/1.12/en/zend.application.available-resources.html
Beware that the following doesn't work, it throws an exception:
resources.mail.transport.type = smtp
We need to use Zend_Mail_Transport_Smtp instead of only smtp. Please see below for the correct answer:
[production]
resources.mail.transport.type = sendmail
[development : production]
resources.mail.transport.type = Zend_Mail_Transport_Smtp
resources.mail.transport.host = "smtp.server.com"
resources.mail.transport.auth = login
resources.mail.transport.username = "myLogin"
resources.mail.transport.password = "myPasswd"
Source: http://framework.zend.com/issues/browse/ZF-9802
精彩评论