ILIAS  release_4-4 Revision
ilBMFTransport_SMTP Class Reference
+ Inheritance diagram for ilBMFTransport_SMTP:
+ Collaboration diagram for ilBMFTransport_SMTP:

Public Member Functions

 ilBMFTransport_SMTP ($URL, $encoding='US-ASCII')
 ilBMFTransport_SMTP Constructor More...
 
 send ($msg, $options=array())
 Sends and receives SOAP data. More...
 
 setCredentials ($username, $password)
 Sets data for HTTP authentication, creates Authorization header. More...
 
 _validateUrl ()
 Validates url data passed to constructor. More...
 
- Public Member Functions inherited from ilBMFBase
 ilBMFBase ($faultcode='Client')
 Constructor. More...
 
 _resetNamespaces ()
 
 _setSchemaVersion ($schemaVersion)
 Sets the schema version used in the SOAP message. More...
 
 _getNamespacePrefix ($ns)
 
 _getNamespaceForPrefix ($prefix)
 
 _isSoapValue (&$value)
 
 _serializeValue (&$value, $name='', $type=false, $elNamespace=NULL, $typeNamespace=NULL, $options=array(), $attributes=array(), $artype='', $OBJTypeNS=array())
 
 _getType (&$value)
 Converts a PHP type to a SOAP type. More...
 
 _multiArrayType (&$value, &$type, &$size, &$xml)
 
 _isBase64 (&$value)
 Returns whether a string is base64 encoded data. More...
 
 _isBase64Type ($type)
 Returns whether a type is a base64 type. More...
 
 _isHash (&$a)
 Returns whether an array is a hash. More...
 
 _un_htmlentities ($string)
 
_decode (&$soapval)
 
 _makeEnvelope (&$method, &$headers, $encoding=SOAP_DEFAULT_ENCODING, $options=array())
 Creates the SOAP envelope with the SOAP envelop data. More...
 
 _makeMimeMessage (&$xml, $encoding=SOAP_DEFAULT_ENCODING)
 
 _makeDIMEMessage ($xml)
 
 _decodeMimeMessage (&$data, &$headers, &$attachments)
 
 _decodeDIMEMessage (&$data, &$headers, &$attachments)
 
 __set_type_translation ($type, $class=null)
 
- Public Member Functions inherited from ilBMFBase_Object
 ilBMFBase_Object ($faultcode='Client')
 Constructor. More...
 
_raiseSoapFault ($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
 Raises a SOAP error. More...
 
 __isfault ()
 
__getfault ()
 
 _debug ($string)
 Adds a string to the debug data. More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $credentials = ''
 
 $timeout = 4
 
 $urlparts = NULL
 
 $url = ''
 
 $incoming_payload = ''
 
 $_userAgent = SOAP_LIBRARY_NAME
 
 $encoding = SOAP_DEFAULT_ENCODING
 
 $host = '127.0.0.1'
 
 $port = 25
 
 $auth = NULL
 
- Data Fields inherited from ilBMFBase
 $_XMLSchema
 
 $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $_typemap
 
 $_defaultObjectClassname = 'stdClass'
 Default class name to use for decoded response objects. More...
 
 $_namespaces
 
 $_namespace
 
 $_xmlEntities
 
 $_doconversion = false
 
 $__attachments = array()
 
 $_wsdl = null
 
 $_section5 = true
 True if we use section 5 encoding, or false if this is literal. More...
 
 $_auto_translation = false
 
 $_type_translation = array()
 
- Data Fields inherited from ilBMFBase_Object
 $_debug_flag = false
 Store debugging information in $_debug_data? More...
 
 $_debug_data = ''
 String containing debugging information if $_debug_flag is true. More...
 
 $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8')
 Supported encodings, limited by XML extension. More...
 
 $_myfaultcode = ''
 Fault code. More...
 
 $fault = null
 Recent PEAR_Error object. More...
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Detailed Description

Definition at line 44 of file class.ilBMFTransport_SMTP.php.

Member Function Documentation

◆ _validateUrl()

ilBMFTransport_SMTP::_validateUrl ( )

Validates url data passed to constructor.

Returns
boolean private

Definition at line 191 of file class.ilBMFTransport_SMTP.php.

References ilBMFBase_Object\_raiseSoapFault().

Referenced by send().

192  {
193  if (!is_array($this->urlparts)) {
194  $this->_raiseSoapFault("Unable to parse URL $url");
195  return false;
196  }
197  if (!isset($this->urlparts['scheme']) ||
198  strcasecmp($this->urlparts['scheme'], 'mailto') != 0) {
199  $this->_raiseSoapFault("Unable to parse URL $url");
200  return false;
201  }
202  if (!isset($this->urlparts['path'])) {
203  $this->_raiseSoapFault("Unable to parse URL $url");
204  return false;
205  }
206  return true;
207  }
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilBMFTransport_SMTP()

ilBMFTransport_SMTP::ilBMFTransport_SMTP (   $URL,
  $encoding = 'US-ASCII' 
)

ilBMFTransport_SMTP Constructor

Parameters
string$URLmailto:address

public

Definition at line 64 of file class.ilBMFTransport_SMTP.php.

References $encoding.

65  {
66  parent::ilBMFBase('SMTP');
67  $this->encoding = $encoding;
68  $this->urlparts = @parse_url($URL);
69  $this->url = $URL;
70  }

◆ send()

ilBMFTransport_SMTP::send (   $msg,
  $options = array() 
)

Sends and receives SOAP data.

Parameters
string$msgOutgoing POST data.
string$actionSOAP Action header data.
integer$timeoutSocket timeout, defaults to 0 or off.
Returns
string Response data, minus HTTP headers. public

Definition at line 82 of file class.ilBMFTransport_SMTP.php.

References $_userAgent, ilBMFBase_Object\$fault, $host, $incoming_payload, $namespace, $options, $out, $result, ilBMFBase\_makeEnvelope(), ilBMFBase_Object\_raiseSoapFault(), _validateUrl(), and PEAR\isError().

83  {
84  $this->incoming_payload = '';
85  $this->outgoing_payload = $msg;
86  if (!$this->_validateUrl()) {
87  return $this->fault;
88  }
89  if (!$options || !isset($options['from'])) {
90  return $this->_raiseSoapFault('No From: address to send message with');
91  }
92 
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'];
98 
99  $headers = array();
100  $headers['From'] = $options['from'];
101  $headers['X-Mailer'] = $this->_userAgent;
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']}\"";
107  }
108 
109  if (isset($options['headers']))
110  $headers = array_merge($headers, $options['headers']);
111 
112  // If the content type is already set, we assume that MIME encoding is
113  // already done.
114  if (isset($headers['Content-Type'])) {
115  $out = $msg;
116  } else {
117  // Do a simple inline MIME encoding.
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'];
123  $out = $msg;
124  } elseif (strcasecmp($options['transfer-encoding'],'base64') == 0) {
125  $headers['Content-Transfer-Encoding'] = 'base64';
126  $out = chunk_split(base64_encode($msg), 76, "\n");
127  } else {
128  return $this->_raiseSoapFault("Invalid Transfer Encoding: {$options['transfer-encoding']}");
129  }
130  } else {
131  // Default to base64.
132  $headers['Content-Transfer-Encoding'] = 'base64';
133  $out = chunk_split(base64_encode($msg));
134  }
135  }
136 
137  $headers['Subject'] = isset($options['subject']) ? $options['subject'] : 'SOAP Message';
138 
139  foreach ($headers as $key => $value) {
140  $header_text .= "$key: $value\n";
141  }
142  $this->outgoing_payload = $header_text . "\r\n" . $this->outgoing_payload;
143 
144  $mailer_params = array(
145  'host' => $this->host,
146  'port' => $this->port,
147  'username' => $this->username,
148  'password' => $this->password,
149  'auth' => $this->auth
150  );
151  $mailer =& new Mail_smtp($mailer_params);
152  $result = $mailer->send($this->urlparts['path'], $headers, $out);
153  if (!PEAR::isError($result)) {
154  $val =& new ilBMFValue('Message-ID', 'string', $headers['Message-ID']);
155  } else {
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);
159  }
160 
161  $mqname =& new QName($method, $namespace);
162  $methodValue =& new ilBMFValue('Response', 'Struct', array($val));
163 
164  $this->incoming_payload = $this->_makeEnvelope($methodValue,
165  $this->headers,
166  $this->encoding);
167 
169  }
if($err=$client->getError()) $namespace
_validateUrl()
Validates url data passed to constructor.
$result
& _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
$fault
Recent PEAR_Error object.
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
+ Here is the call graph for this function:

◆ setCredentials()

ilBMFTransport_SMTP::setCredentials (   $username,
  $password 
)

Sets data for HTTP authentication, creates Authorization header.

Parameters
string$usernameUsername.
string$passwordResponse data, minus HTTP headers.

public

Definition at line 179 of file class.ilBMFTransport_SMTP.php.

180  {
181  $this->username = $username;
182  $this->password = $password;
183  }

Field Documentation

◆ $_userAgent

ilBMFTransport_SMTP::$_userAgent = SOAP_LIBRARY_NAME

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

Referenced by send().

◆ $auth

ilBMFTransport_SMTP::$auth = NULL

Definition at line 56 of file class.ilBMFTransport_SMTP.php.

◆ $credentials

ilBMFTransport_SMTP::$credentials = ''

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

◆ $encoding

ilBMFTransport_SMTP::$encoding = SOAP_DEFAULT_ENCODING

Definition at line 53 of file class.ilBMFTransport_SMTP.php.

Referenced by ilBMFTransport_SMTP().

◆ $host

ilBMFTransport_SMTP::$host = '127.0.0.1'

Definition at line 54 of file class.ilBMFTransport_SMTP.php.

Referenced by send().

◆ $incoming_payload

ilBMFTransport_SMTP::$incoming_payload = ''

Definition at line 51 of file class.ilBMFTransport_SMTP.php.

Referenced by send().

◆ $port

ilBMFTransport_SMTP::$port = 25

Definition at line 55 of file class.ilBMFTransport_SMTP.php.

◆ $timeout

ilBMFTransport_SMTP::$timeout = 4

Definition at line 48 of file class.ilBMFTransport_SMTP.php.

◆ $url

ilBMFTransport_SMTP::$url = ''

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

◆ $urlparts

ilBMFTransport_SMTP::$urlparts = NULL

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


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