diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php index 335df2bf40b397780bb1e3a4ec164f6864e32232..9638920e940b5f8dd1cedb190f15f49fc0fc7272 100644 --- a/lib/SimpleSAML/XHTML/EMail.php +++ b/lib/SimpleSAML/XHTML/EMail.php @@ -6,22 +6,22 @@ * @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ -class SimpleSAML_XHTML_EMail { - - - private $to = NULL; - private $cc = NULL; - private $body = NULL; - private $from = NULL; - private $replyto = NULL; - private $subject = NULL; +class SimpleSAML_XHTML_EMail +{ + private $to = null; + private $cc = null; + private $body = null; + private $from = null; + private $replyto = null; + private $subject = null; private $headers = array(); /** * Constructor */ - function __construct($to, $subject, $from = NULL, $cc = NULL, $replyto = NULL) { + public function __construct($to, $subject, $from = null, $cc = null, $replyto = null) + { $this->to = $to; $this->cc = $cc; $this->from = $from; @@ -29,10 +29,20 @@ class SimpleSAML_XHTML_EMail { $this->subject = $subject; } - function setBody($body) { + /* + * @param string $body + * @return void + */ + public function setBody($body) + { $this->body = $body; } - + + + /* + * @param string $body + * @return void + */ private function getHTML($body) { return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -60,10 +70,19 @@ pre { </html>'; } - function send() { - if ($this->to == NULL) throw new Exception('EMail field [to] is required and not set.'); - if ($this->subject == NULL) throw new Exception('EMail field [subject] is required and not set.'); - if ($this->body == NULL) throw new Exception('EMail field [body] is required and not set.'); + + /* + * @return void + */ + public function send() + { + if ($this->to === null) { + throw new Exception('EMail field [to] is required and not set.'); + } elseif ($this->subject === null) { + throw new Exception('EMail field [subject] is required and not set.'); + } elseif ($this->body === null) { + throw new Exception('EMail field [body] is required and not set.'); + } $random_hash = bin2hex(openssl_random_pseudo_bytes(16)); @@ -93,7 +112,8 @@ Content-Transfer-Encoding: 8bit $mail_sent = @mail($this->to, $this->subject, $message, $headers); SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed')); - if (!$mail_sent) throw new Exception('Error when sending e-mail'); + if (!$mail_sent) { + throw new Exception('Error when sending e-mail'); + } } - }