29 require_once dirname(__FILE__).
'/../class.ilBMFBase.php';
30 require_once
'Mail/smtp.php';
66 parent::ilBMFBase(
'SMTP');
68 $this->urlparts = @parse_url($URL);
84 $this->incoming_payload =
'';
85 $this->outgoing_payload = $msg;
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']}\"";
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'])) {
if($err=$client->getError()) $namespace
_validateUrl()
Validates url data passed to constructor.
send($msg, $options=array())
Sends and receives SOAP data.
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
_makeEnvelope(&$method, &$headers, $encoding=SOAP_DEFAULT_ENCODING, $options=array())
Creates the SOAP envelope with the SOAP envelop data.
if(!is_array($argv)) $options
setCredentials($username, $password)
Sets data for HTTP authentication, creates Authorization header.
const SOAP_DEFAULT_ENCODING
$fault
Recent PEAR_Error object.
ilBMFTransport_SMTP($URL, $encoding='US-ASCII')
ilBMFTransport_SMTP Constructor
isError($data, $code=null)
Tell whether a value is a PEAR error.