29 require_once dirname(__FILE__).
'/../class.ilBMFBase.php';
30 require_once
'Mail/smtp.php';
68 $this->urlparts = @parse_url($URL);
82 function send($msg, $options = array())
84 $this->incoming_payload =
'';
85 $this->outgoing_payload = $msg;
89 if (!$options || !isset($options[
'from'])) {
93 if (isset($options[
'host'])) $this->host = $options[
'host'];
94 if (isset($options[
'port'])) $this->port = $options[
'port'];
95 if (isset($options[
'auth'])) $this->auth = $options[
'auth'];
96 if (isset($options[
'username'])) $this->username = $options[
'username'];
97 if (isset($options[
'password'])) $this->password = $options[
'password'];
100 $headers[
'From'] = $options[
'from'];
102 $headers[
'MIME-Version'] =
'1.0';
103 $headers[
'Message-ID'] = md5(time()) .
'.soap@' .
$this->host;
104 $headers[
'To'] = $this->urlparts[
'path'];
105 if (isset($options[
'soapaction'])) {
106 $headers[
'Soapaction'] =
"\"{$options['soapaction']}\"";
109 if (isset($options[
'headers']))
110 $headers = array_merge($headers, $options[
'headers']);
114 if (isset($headers[
'Content-Type'])) {
118 $headers[
'Content-Disposition'] =
'inline';
119 $headers[
'Content-Type'] =
"text/xml; charset=\"$this->encoding\"";
120 if (isset($options[
'transfer-encoding'])) {
121 if (strcasecmp($options[
'transfer-encoding'],
'quoted-printable') == 0) {
122 $headers[
'Content-Transfer-Encoding'] = $options[
'transfer-encoding'];
124 } elseif (strcasecmp($options[
'transfer-encoding'],
'base64') == 0) {
125 $headers[
'Content-Transfer-Encoding'] =
'base64';
126 $out = chunk_split(base64_encode($msg), 76,
"\n");
128 return $this->
_raiseSoapFault(
"Invalid Transfer Encoding: {$options['transfer-encoding']}");
132 $headers[
'Content-Transfer-Encoding'] =
'base64';
133 $out = chunk_split(base64_encode($msg));
137 $headers[
'Subject'] = isset($options[
'subject']) ? $options[
'subject'] :
'SOAP Message';
139 foreach ($headers as $key => $value) {
140 $header_text .=
"$key: $value\n";
142 $this->outgoing_payload = $header_text .
"\r\n" . $this->outgoing_payload;
144 $mailer_params = array(
145 'host' => $this->host,
146 'port' => $this->port,
147 'username' => $this->username,
148 'password' => $this->password,
149 'auth' => $this->auth
151 $mailer =&
new Mail_smtp($mailer_params);
152 $result = $mailer->send($this->urlparts[
'path'], $headers,
$out);
154 $val =&
new ilBMFValue(
'Message-ID',
'string', $headers[
'Message-ID']);
156 $sval[] =&
new ilBMFValue(
'faultcode',
'QName',
'SOAP-ENV:Client');
157 $sval[] =&
new ilBMFValue(
'faultstring',
'string',
"couldn't send SMTP message to {$this->urlparts['path']}");
158 $val =&
new ilBMFValue(
'Fault',
'Struct', $sval);
162 $methodValue =&
new ilBMFValue(
'Response',
'Struct', array($val));
181 $this->username = $username;
182 $this->password = $password;
193 if (!is_array($this->urlparts)) {
197 if (!isset($this->urlparts[
'scheme']) ||
198 strcasecmp($this->urlparts[
'scheme'],
'mailto') != 0) {
202 if (!isset($this->urlparts[
'path'])) {