Public Member Functions | Data Fields

ilBMFServer_Email_Gateway Class Reference

Inheritance diagram for ilBMFServer_Email_Gateway:
Collaboration diagram for ilBMFServer_Email_Gateway:

Public Member Functions

 ilBMFServer_Email_Gateway ($gateway= '', $send_response=TRUE, $dump=FALSE)
 service (&$data, $gateway='', $endpoint= '', $send_response=TRUE, $dump=FALSE)

Data Fields

 $gateway = NULL
 $dump = FALSE

Detailed Description

Definition at line 47 of file class.ilBMFServer_Email_Gateway.php.


Member Function Documentation

ilBMFServer_Email_Gateway::ilBMFServer_Email_Gateway ( gateway = '',
send_response = TRUE,
dump = FALSE 
)

Definition at line 52 of file class.ilBMFServer_Email_Gateway.php.

References $dump, $gateway, and ilBMFServer::ilBMFServer().

    {
        parent::ilBMFServer();
        $this->send_response = $send_response;
        $this->gateway = $gateway;
        $this->dump = $dump;
    }

Here is the call graph for this function:

ilBMFServer_Email_Gateway::service ( &$  data,
gateway = '',
endpoint = '',
send_response = TRUE,
dump = FALSE 
)

Definition at line 60 of file class.ilBMFServer_Email_Gateway.php.

References $data, $dump, ilBMFServer::$endpoint, $gateway, ilBMFServer_Email::$headers, ilBMFBase::_makeDIMEMessage(), ilBMFBase::_makeMimeMessage(), ilBMFServer_Email::_parseEmail(), ilBMFBase_Object::_raiseSoapFault(), and ilBMFTransport::getTransport().

    {
        $this->endpoint = $endpoint;
        $response = '';
        $useEncoding='Mime';
        $options = array();
        if (!$gateway) $gateway = $this->gateway;
        
        // we have a full set of headers, need to find the first blank line
        $this->_parseEmail($data);
        if ($this->fault) {
            $response = $this->fault->message();
        }
        if ($this->headers['content-type']=='application/dime')
            $useEncoding='DIME';
        
        # call the HTTP Server
        if (!$response) {
            $soap_transport =& ilBMFTransport::getTransport($gateway, $this->xml_encoding);
            if ($soap_transport->fault) {
                $response = $soap_transport->fault->message();
            }
        }
        
        // send the message
        if (!$response) {
            $options['soapaction'] = $this->headers['soapaction'];
            $options['headers']['Content-Type'] = $this->headers['content-type'];
            
            $response = $soap_transport->send($data, $options);
            if (isset($this->headers['mime-version']))
                $options['headers']['MIME-Version'] = $this->headers['mime-version'];
            
            if ($soap_transport->fault) {
                $response = $soap_transport->fault->message();
            } else {
                foreach ($soap_transport->transport->attachments as $cid=>$body) {
                    $this->attachments[] = array('body' => $body, 'cid' => $cid, 'encoding' => 'base64');
                }
                if (count($this->__attachments)) {
                    if ($useEncoding == 'Mime') {
                        $soap_msg = $this->_makeMimeMessage($response);
                        $options['headers']['MIME-Version'] = '1.0';
                    } else {
                        // default is dime
                        $soap_msg = $this->_makeDIMEMessage($response);
                        $options['headers']['Content-Type'] = 'application/dime';
                    }
                    if (PEAR::isError($soap_msg)) {
                        return $this->_raiseSoapFault($soap_msg);
                    }
                    if (is_array($soap_msg)) {
                        $response = $soap_msg['body'];
                        if (count($soap_msg['headers'])) {
                            if (isset($options['headers'])) {
                                $options['headers'] = array_merge($options['headers'],$soap_msg['headers']);
                            } else {
                                $options['headers'] = $soap_msg['headers'];
                            }
                        }
                    }
                }
            }
        }
        
        if ($this->send_response) {        
            if ($this->dump || $dump) {
                print $response;
            } else {
                $from = array_key_exists('reply-to',$this->headers) ? $this->headers['reply-to']:$this->headers['from'];
                # XXX what if no from?????
                
                $soap_transport =& ilBMFTransport::getTransport('mailto:'.$from, $this->response_encoding);
                $from = $this->endpoint ? $this->endpoint : $this->headers['to'];
                $headers = array('In-Reply-To'=>$this->headers['message-id']);
                $options = array('from' => $from, 'subject'=> $this->headers['subject'], 'headers' => $headers);
                $soap_transport->send($response, $options);
            }
        }
    }    

Here is the call graph for this function:


Field Documentation

ilBMFServer_Email_Gateway::$dump = FALSE

Definition at line 50 of file class.ilBMFServer_Email_Gateway.php.

Referenced by ilBMFServer_Email_Gateway(), and service().

ilBMFServer_Email_Gateway::$gateway = NULL

Definition at line 49 of file class.ilBMFServer_Email_Gateway.php.

Referenced by ilBMFServer_Email_Gateway(), and service().


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