シンプルな日本語メール送信クラスです。サーバーの文字コードはUTF-8とした場合。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | class mailsender {   private $mail_to = null;   private $from = null;   private $from_name = null;   private $subject = '(件名なし)';   private $body = '(本文なし)';   function set_mail_to($val) {     $this->mail_to = $val;   }   function set_from($f, $fn = null) {     $this->from = $f;     $this->from_name = $fn;   }   function set_subject($val) {     $this->subject = $val;   }   function set_body($val) {     $this->body = $val;   }   public function send() {     global $CONST;     if($this->mail_to == null) {       return false;     }     if($this->from == null) {       return false;     }     mb_language("japanese");     mb_internal_encoding("UTF-8");     $to = $this->mail_to;     $subject = $this->subject;     $body = $this->body;     if($this->from_name != null) {       $from_name = '=?UTF-8?B?' . base64_encode($this->from_name) . '?=';       $header = "From: " . $from_name . "<" . $this->from . ">\n";     }     else {       $header = "From: " . $this->from . "\n";     }     $ret = mb_send_mail($to,$subject,$body,$header);     return $ret;   } } | 
