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))
72 if (isset($this->replyto))
74
75 $this->headers[] = 'Content-Type: multipart/alternative; boundary="simplesamlphp-' . $random_hash . '"';
76
78--simplesamlphp-' . $random_hash . '
79Content-Type: text/plain; charset="utf-8"
80Content-Transfer-Encoding: 8bit
81
82' . strip_tags(html_entity_decode($this->body)) . '
83
84--simplesamlphp-' . $random_hash . '
85Content-Type: text/html; charset="utf-8"
86Content-Transfer-Encoding: 8bit
87
88' . $this->
getHTML($this->body) .
'
89
90--simplesamlphp-' . $random_hash . '--
91';
92 $headers = implode(
"\n", $this->headers);
93
96 if (!$mail_sent) throw new Exception('Error when sending e-mail');
97 }
catch(Exception $e) $message
mail($to, $subject, $message, $additional_headers=null, $additional_parameters=null)