ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleSAML_XHTML_EMail Class Reference
+ Collaboration diagram for SimpleSAML_XHTML_EMail:

Public Member Functions

 __construct ($to, $subject, $from=NULL, $cc=NULL, $replyto=NULL)
 Constructor. More...
 
 setBody ($body)
 
 send ()
 

Private Member Functions

 getHTML ($body)
 

Private Attributes

 $to = NULL
 
 $cc = NULL
 
 $body = NULL
 
 $from = NULL
 
 $replyto = NULL
 
 $subject = NULL
 
 $headers = array()
 

Detailed Description

Definition at line 9 of file EMail.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_XHTML_EMail::__construct (   $to,
  $subject,
  $from = NULL,
  $cc = NULL,
  $replyto = NULL 
)

Constructor.

Definition at line 24 of file EMail.php.

References $cc, $from, $replyto, $subject, $to, and to.

24  {
25  $this->to = $to;
26  $this->cc = $cc;
27  $this->from = $from;
28  $this->replyto = $replyto;
29  $this->subject = $subject;
30  }
File written to

Member Function Documentation

◆ getHTML()

SimpleSAML_XHTML_EMail::getHTML (   $body)
private

Definition at line 36 of file EMail.php.

References $body.

Referenced by send().

36  {
37  return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
38  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
40 <head>
41  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
42  <title>SimpleSAMLphp Email report</title>
43  <style type="text/css">
44 pre, div.box {
45  margin: .4em 2em .4em 1em;
46  padding: 4px;
47 
48 }
49 pre {
50  background: #eee;
51  border: 1px solid #aaa;
52 }
53  </style>
54 </head>
55 <body>
56 <div class="container" style="background: #fafafa; border: 1px solid #eee; margin: 2em; padding: .6em;">
57 ' . $body . '
58 </div>
59 </body>
60 </html>';
61  }
+ Here is the caller graph for this function:

◆ send()

SimpleSAML_XHTML_EMail::send ( )

Definition at line 63 of file EMail.php.

References $from, $headers, $message, $replyto, SimpleSAML\Logger\debug(), getHTML(), Monolog\Handler\mail(), and to.

63  {
64  if ($this->to == NULL) throw new Exception('EMail field [to] is required and not set.');
65  if ($this->subject == NULL) throw new Exception('EMail field [subject] is required and not set.');
66  if ($this->body == NULL) throw new Exception('EMail field [body] is required and not set.');
67 
68  $random_hash = bin2hex(openssl_random_pseudo_bytes(16));
69 
70  if (isset($this->from))
71  $this->headers[]= 'From: ' . $this->from;
72  if (isset($this->replyto))
73  $this->headers[]= 'Reply-To: ' . $this->replyto;
74 
75  $this->headers[] = 'Content-Type: multipart/alternative; boundary="simplesamlphp-' . $random_hash . '"';
76 
77  $message = '
78 --simplesamlphp-' . $random_hash . '
79 Content-Type: text/plain; charset="utf-8"
80 Content-Transfer-Encoding: 8bit
81 
82 ' . strip_tags(html_entity_decode($this->body)) . '
83 
84 --simplesamlphp-' . $random_hash . '
85 Content-Type: text/html; charset="utf-8"
86 Content-Transfer-Encoding: 8bit
87 
88 ' . $this->getHTML($this->body) . '
89 
90 --simplesamlphp-' . $random_hash . '--
91 ';
92  $headers = implode("\n", $this->headers);
93 
94  $mail_sent = @mail($this->to, $this->subject, $message, $headers);
95  SimpleSAML\Logger::debug('Email: Sending e-mail to [' . $this->to . '] : ' . ($mail_sent ? 'OK' : 'Failed'));
96  if (!$mail_sent) throw new Exception('Error when sending e-mail');
97  }
File written to
static debug($string)
Definition: Logger.php:213
mail($to, $subject, $message, $additional_headers=null, $additional_parameters=null)
catch(Exception $e) $message
+ Here is the call graph for this function:

◆ setBody()

SimpleSAML_XHTML_EMail::setBody (   $body)

Definition at line 32 of file EMail.php.

References $body.

32  {
33  $this->body = $body;
34  }

Field Documentation

◆ $body

SimpleSAML_XHTML_EMail::$body = NULL
private

Definition at line 14 of file EMail.php.

Referenced by getHTML(), and setBody().

◆ $cc

SimpleSAML_XHTML_EMail::$cc = NULL
private

Definition at line 13 of file EMail.php.

Referenced by __construct().

◆ $from

SimpleSAML_XHTML_EMail::$from = NULL
private

Definition at line 15 of file EMail.php.

Referenced by __construct(), and send().

◆ $headers

SimpleSAML_XHTML_EMail::$headers = array()
private

Definition at line 18 of file EMail.php.

Referenced by send().

◆ $replyto

SimpleSAML_XHTML_EMail::$replyto = NULL
private

Definition at line 16 of file EMail.php.

Referenced by __construct(), and send().

◆ $subject

SimpleSAML_XHTML_EMail::$subject = NULL
private

Definition at line 17 of file EMail.php.

Referenced by __construct().

◆ $to

SimpleSAML_XHTML_EMail::$to = NULL
private

Definition at line 12 of file EMail.php.

Referenced by __construct().


The documentation for this class was generated from the following file: