Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created May 4, 2011 07:13
Show Gist options
  • Save nissuk/954865 to your computer and use it in GitHub Desktop.
Save nissuk/954865 to your computer and use it in GitHub Desktop.
CakePHP: QdmailComponentをコントローラの$componentsで初期化できるようにする
<?php
/*
* QdmailComponentをコントローラの$componentsで初期化できるようにしたコンポーネントです(実験的)。
*
* 使用例 (コントローラ内)
* var $components = array('XQdmail' => array(
'smtp' => true,
'smtpServer' => array(
'host' => 'ssl://smtp.gmail.com' ,
'port' => '465',
'user' => '{{example}}@gmail.com',
'pass' => '{{パスワード}}',
'protocol' => 'SMTP_AUTH',
)
));
*
* @license Public domain
*/
App::import('Component', 'Qdmail');
class XQdmailComponent extends QdmailComponent {
function initialize(&$controller, $settings) {
$this->set($settings);
}
/*
* Qdmailの設定を一括で行います。
*
* 使用例
* $this->XQdmail->set(array(
'from' => '{{example}}@gmail.com',
'to' => '[email protected]',
'subject' => 'お問い合わせ',
'text' => 'お問い合わせが届きました…(略)'
));
$this->XQdmail->send();
*/
function set($settings) {
foreach ($settings as $key => $value) {
$this->{$key}($value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment