Skip to content
Snippets Groups Projects
Unverified Commit fd9bf496 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

PSR-2 + phpdoc

parent a8f60543
No related branches found
No related tags found
No related merge requests found
...@@ -6,22 +6,22 @@ ...@@ -6,22 +6,22 @@
* @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
class SimpleSAML_XHTML_EMail { class SimpleSAML_XHTML_EMail
{
private $to = null;
private $to = NULL; private $cc = null;
private $cc = NULL; private $body = null;
private $body = NULL; private $from = null;
private $from = NULL; private $replyto = null;
private $replyto = NULL; private $subject = null;
private $subject = NULL;
private $headers = array(); private $headers = array();
/** /**
* Constructor * 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->to = $to;
$this->cc = $cc; $this->cc = $cc;
$this->from = $from; $this->from = $from;
...@@ -29,10 +29,20 @@ class SimpleSAML_XHTML_EMail { ...@@ -29,10 +29,20 @@ class SimpleSAML_XHTML_EMail {
$this->subject = $subject; $this->subject = $subject;
} }
function setBody($body) { /*
* @param string $body
* @return void
*/
public function setBody($body)
{
$this->body = $body; $this->body = $body;
} }
/*
* @param string $body
* @return void
*/
private function getHTML($body) { private function getHTML($body) {
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...@@ -60,10 +70,19 @@ pre { ...@@ -60,10 +70,19 @@ pre {
</html>'; </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.'); * @return void
if ($this->body == NULL) throw new Exception('EMail field [body] is required and not set.'); */
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)); $random_hash = bin2hex(openssl_random_pseudo_bytes(16));
...@@ -93,7 +112,8 @@ Content-Transfer-Encoding: 8bit ...@@ -93,7 +112,8 @@ Content-Transfer-Encoding: 8bit
$mail_sent = @mail($this->to, $this->subject, $message, $headers); $mail_sent = @mail($this->to, $this->subject, $message, $headers);
SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed')); 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');
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment