Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # cake&qdsmtp SMTP-AUTH LOGIN認証を簡易的にやってみる
- # qdsmtp.php
- // var $smtp_auth_kind = array('PLAIN');
- var $smtp_auth_kind = array('PLAIN','LOGIN');
- function login(){
- $login = $this->makeLogin();
- return true;
- }
- function makeLogin() {
- fwrite($this->sock, "AUTH LOGIN\r\n");
- $res = fgets($this->sock);
- $arrRes = explode(" ", $res);
- if($arrRes[0] == '334') {
- $user = base64_encode($this->smtp_param['USER']);
- $pass = base64_encode($this->smtp_param['PASS']);
- fwrite($this->sock, $user."\r\n");
- fgets($this->sock);
- fwrite($this->sock, $pass."\r\n");
- }
- fgets($this->sock);
- $login[0] = $user." ".$pass;
- return $login;
- }
- # hoge_controller.php
- var $qdsmtp_params = array(
- 'host' => 'ssl://xxx.jp',
- 'port' => '465',
- 'from' => 'xxx@xxx.jp',
- 'protocol' => 'SMTP_AUTH',
- 'user' => 'xxx@xxx.jp',
- 'pass' => 'xxx',
- );
- $this->Qdmail->smtp(true);
- $this->Qdmail->smtpServer($this->qdsmtp_params);
- $this->Qdmail->from();
- $this->Qdmail->to();
- $this->Qdmail->subject();
- $this->Qdmail->text();
- $this->Qdmail->send();
Add Comment
Please, Sign In to add comment