Guest User

Untitled

a guest
Oct 18th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. # cake&qdsmtp SMTP-AUTH LOGIN認証を簡易的にやってみる
  3.  
  4. # qdsmtp.php
  5. // var $smtp_auth_kind = array('PLAIN');
  6. var $smtp_auth_kind = array('PLAIN','LOGIN');
  7.  
  8. function login(){
  9. $login = $this->makeLogin();
  10. return true;
  11. }
  12.  
  13. function makeLogin() {
  14. fwrite($this->sock, "AUTH LOGIN\r\n");
  15. $res = fgets($this->sock);
  16. $arrRes = explode(" ", $res);
  17. if($arrRes[0] == '334') {
  18. $user = base64_encode($this->smtp_param['USER']);
  19. $pass = base64_encode($this->smtp_param['PASS']);
  20. fwrite($this->sock, $user."\r\n");
  21. fgets($this->sock);
  22. fwrite($this->sock, $pass."\r\n");
  23. }
  24. fgets($this->sock);
  25. $login[0] = $user." ".$pass;
  26. return $login;
  27. }
  28.  
  29.  
  30. # hoge_controller.php
  31. var $qdsmtp_params = array(
  32. 'host' => 'ssl://xxx.jp',
  33. 'port' => '465',
  34. 'from' => 'xxx@xxx.jp',
  35. 'protocol' => 'SMTP_AUTH',
  36. 'user' => 'xxx@xxx.jp',
  37. 'pass' => 'xxx',
  38. );
  39.  
  40. $this->Qdmail->smtp(true);
  41. $this->Qdmail->smtpServer($this->qdsmtp_params);
  42. $this->Qdmail->from();
  43. $this->Qdmail->to();
  44. $this->Qdmail->subject();
  45. $this->Qdmail->text();
  46. $this->Qdmail->send();
Add Comment
Please, Sign In to add comment