<?php

require('message.inc');


class Contact_Mail extends Message {
	
	private $to = 'Martin Stadler <martin@siarp.de>, Tilman Walther <tilman@tilman.de>';
	private $subject = 'Post für Beethoven2000';
	private $from = 'From: Beethoven2000 Kontaktformular <abi@beethoven2000.de>';
	
	/**
	 * Sendet die Mail mit den Übergebenen Parametern.
	 */
	function __construct ($name, $address, $message) {
		
		if ($this->contains_spam_hints($name . $address . $message, array($name, $address))) {
			$this->spam = true;
			return true;
		}
		
		/* check for missing '@' in address as a spam hint */
		/* XXX dirty */
		if (!empty($address) && strpos($address, '@') === false) {
			$this->spam = true;
			return true;
		}
				
		$contents = 'Name: ' . $name . "\n";
		$contents .= 'eMail: ' . $address . "\n";
		$contents .= "\n--------\n";
		$contents .= utf8_decode(preg_replace('~\r~', '', $message));
		
		if (!mail($this->to, $this->subject, $contents, $this->from)) {
			$this->error = true;
		}
	}
}

?>