書き置き。

ほぼ勉強の記録みたいなもんです。

ShellからQdmailを使用してメール送信を行う方法

shellクラスの外側でControllerとQdmailを読み込んでおく

App::import("Core","Controller");
App::import("Component","Qdmail");

(中略)

function send(){
    $this->Qdmail = new QdmailComponent();
    $this->Qdmail->Controller = new Controller();

    //このへんはお好みで
    $this->Qdmail->to($this->_from); //送信元に送り返す
    $this->Qdmail->from($this->_to); //fromは元宛先アドレス
    $this->Qdmail->subject(__('auto reply',true));


    //テンプレートに渡したい値は$contentsに詰め込む
    //mail_regist.ctpをrenderしてメール本文に使用する
    $this->Qdmail->cakeText($contents,"mail_regist");
    $res = $this->Qdmail->send();
//以下略

}