cakephp swiftmailer config -
hi using swiftmailer component in app , looking way have separate config (perhaps in config folder?) swiftmailer checks debug mode using , uses different settings?
case 1: on production mode use simple smtp server without auth. case 2: on debug mode use gmail settings or other settings since developing locally
is possible?
the settings code case 1:
$this->swiftmailer->smtphost = '';
the settings code case 2:
$this->swiftmailer->smtptype = ''; $this->swiftmailer->smtphost = ''; $this->swiftmailer->smtpport =; $this->swiftmailer->smtpusername = ''; $this->swiftmailer->smtppassword = '';
i think quickest way be:
<?php configure::load('swiftmailer'); $this->swiftmailer->smtptype = configure::read('swiftmailer.'.configure::read().'.smtptype'); $this->swiftmailer->smtphost = configure::read('swiftmailer.'.configure::read().'.smtphost'); $this->swiftmailer->smtpport = configure::read('swiftmailer.'.configure::read().'.smtpport'); $this->swiftmailer->smtpusername = configure::read('swiftmailer.'.configure::read().'.smtpusername'); $this->swiftmailer->smtppassword = configure::read('swiftmailer.'.configure::read().'.smtppassword'); ?>
now put on. suggest controller constructor, way it's nice , tidy. values can use private config file:
// /app/config/swiftmailer.php: <?php $config['swiftmailer'][0]['smtptype'] = 'value'; $config['swiftmailer'][0]['smtphost'] = 'value'; $config['swiftmailer'][0]['smtpport'] = 'value'; $config['swiftmailer'][0]['smtpusername'] = 'value'; $config['swiftmailer'][0]['smtppassword'] = 'value'; $config['swiftmailer'][1]['smtptype'] = 'value'; $config['swiftmailer'][1]['smtphost'] = 'value'; $config['swiftmailer'][1]['smtpport'] = 'value'; $config['swiftmailer'][1]['smtpusername'] = 'value'; $config['swiftmailer'][1]['smtppassword'] = 'value'; $config['swiftmailer'][2]['smtptype'] = 'value'; $config['swiftmailer'][2]['smtphost'] = 'value'; $config['swiftmailer'][2]['smtpport'] = 'value'; $config['swiftmailer'][2]['smtpusername'] = 'value'; $config['swiftmailer'][2]['smtppassword'] = 'value'; ?>
you can find more generic example on configuration class v 1.2 , configuration class v 1.3.
they seem have same content, seems hasn't changed 1.2 1.3.
hope helps.
Comments
Post a Comment