79 {
80 if ($this->to === null) {
81 throw new Exception('EMail field [to] is required and not set.');
82 } elseif ($this->subject === null) {
83 throw new Exception('EMail field [subject] is required and not set.');
84 } elseif ($this->body === null) {
85 throw new Exception('EMail field [body] is required and not set.');
86 }
87
88 $random_hash = bin2hex(openssl_random_pseudo_bytes(16));
89
90 if (isset($this->from)) {
92 }
93 if (isset($this->replyto)) {
95 }
96
97 $this->headers[] = 'Content-Type: multipart/alternative; boundary="simplesamlphp-' . $random_hash . '"';
98
100--simplesamlphp-' . $random_hash . '
101Content-Type: text/plain; charset="utf-8"
102Content-Transfer-Encoding: 8bit
103
104' . strip_tags(html_entity_decode($this->body)) . '
105
106--simplesamlphp-' . $random_hash . '
107Content-Type: text/html; charset="utf-8"
108Content-Transfer-Encoding: 8bit
109
110' . $this->
getHTML($this->body) .
'
111
112--simplesamlphp-' . $random_hash . '--
113';
114 $headers = implode(
"\n", $this->headers);
115
118 if (!$mail_sent) {
119 throw new Exception('Error when sending e-mail');
120 }
121 }
catch(Exception $e) $message
mail($to, $subject, $message, $additional_headers=null, $additional_parameters=null)