header[$name][] = $value; } public function env_from($value) { $this->env_from = $value; } private function content_type($file) { if (($fh = popen('/usr/bin/file -i -b ' . escapeshellarg($file), 'r')) !== false) { $type = fread($fh, 1024); fclose($fh); $parts = explode(';', $type); return trim($parts[0]); } else return mime_content_type($file); } public function attach($filename,$basename=false,$content_type=false) { } public function send($body) { if (!array_key_exists('From', $this->header)) throw new Exception('No sender given.'); if (!array_key_exists('To', $this->header)) throw new Exception('No recipient given.'); if (!array_key_exists('Subject', $this->header)) throw new Exception('No subject given.'); if (empty($body)) throw new Exception('Mail body empty.'); if (!array_key_exists('Content-Type', $this->header)) $this->set('Content-Type', 'text/plain; charset=UTF-8'); if (!array_key_exists('Content-Disposition', $this->header)) $this->set('Content-Disposition', 'inline'); if (!array_key_exists('Content-Transfer-Encoding', $this->header)) $this->set('Content-Transfer-Encoding', '8bit'); $header = ''; foreach ($this->header as $name => $values) { if ($name == 'To' || $name == 'Subject') continue; else $header .= $name . ': ' . implode(', ', $values) . "\r\n"; } $opts = '-t'; $opts .= strlen($this->env_from) ? ' -f '.$this->env_from : ''; $result = mail(implode(',',$this->header['To']), $this->header['Subject'][0], $body, $header, $opts); return $result; } } ?>