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;
}
}