php - How can i send dynamic data in bootstrap file for Email in zend framework -
i sending email user while registration. using zend's default function. added code in bootstrap file.
protected function _initmail() { seek { $config = array( 'auth' => 'login', 'username' => 'username@gmail.com', 'password' => 'password', 'ssl' => 'tls', 'port' => 587 ); $mailtransport = new zend_mail_transport_smtp('smtp.gmail.com', $config); zend_mail::setdefaulttransport($mailtransport); } grab (zend_exception $e){ } }
now need username,password , port want create field dynamic. want fetch record database. can please tell me how can solve problem. help appreciated.
i not set these database. improve way set them config file , set them there. doing database phone call every single time application called not optimal.
the way should doing is:
protected function _initmail() { seek { $config = zend_controller_front::getinstance()->getparam('bootstrap'); $config = $config->getoption("mail"); $mailtransport = new zend_mail_transport_smtp('smtp.gmail.com', $config); zend_mail::setdefaulttransport($mailtransport); } grab (zend_exception $e){ } }
that assuming application.ini has this:
mail.auth="login" mail.username="username@gmail.com" mail.password="password" mail.ssl="tls" mail.port=587
however if decide want this, , have set database in application.ini file (assuming utilize ini files config) this:
resources.db.adapter = "pdo_mysql" resources.db.params.host = "your.database.host" resources.db.params.dbname = "database_name" resources.db.params.username = "username" resources.db.params.password = "password" resources.db.isdefaulttableadapter = true
you can do:
protected function _initmail() { $resource = $bootstrap->getpluginresource('db'); $db = $resource->getdbadapter(); $select=$db->select()->from("emailsetup"); $credentials=$db->fetchone($select); [..email part here..] }
p.s. have not tested select, should gist of it.
php zend-framework
No comments:
Post a Comment