Source for file SMTP.php
Documentation is available at SMTP.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Shane Caraveo <Shane@Caraveo.com> |
// +----------------------------------------------------------------------+
// $Id: SMTP.php,v 1.17 2003/04/13 21:38:58 shane Exp $
// Status: rough draft, untested
// switch to pear mail stuff
// ability to define smtp options (encoding, from, etc.)
require_once 'SOAP/Base.php';
require_once 'Mail/smtp.php';
* SMTP Transport for SOAP
* implements SOAP-SMTP as defined at
* http://www.pocketsoap.com/specs/smtpbinding/
* TODO: use PEAR smtp and Mime classes
* @version $Id: SMTP.php,v 1.17 2003/04/13 21:38:58 shane Exp $
* @package SOAP::Transport::SMTP
* @author Shane Caraveo <shane@php.net>
var $_userAgent = SOAP_LIBRARY_NAME;
* SOAP_Transport_SMTP Constructor
* @param string $URL mailto:address
* send and receive soap data
* @param string &$msg outgoing post data
* @param string $action SOAP Action header data
* @param int $timeout socket timeout, default 0 or off
* @return string &$response response data, minus http headers
function send(&$msg, /*array*/ $options = NULL )
$this->outgoing_payload = &$msg;
if (!$this->_validateUrl ()) {
return $this->_raiseSoapFault ("No FROM address to send message with");
if (isset ($options['host'])) $this->host = $options['host'];
if (isset ($options['port'])) $this->port = $options['port'];
if (isset ($options['auth'])) $this->auth = $options['auth'];
if (isset ($options['username'])) $this->username = $options['username'];
if (isset ($options['password'])) $this->password = $options['password'];
$headers['From'] = $options['from'];
$headers['X-Mailer'] = $this->_userAgent;
$headers['MIME-Version'] = '1.0';
$headers['Message-ID'] = md5(time()). '.soap@'. $this->host;
$headers['To'] = $this->urlparts['path'];
$headers['Soapaction'] = " \"{$options['soapaction']}\"";
if (isset ($options['headers']))
// if the content type is already set, we assume that Mime encoding
if (isset ($headers['Content-Type'])) {
// do a simple inline Mime encoding
$headers['Content-Disposition'] = 'inline';
$headers['Content-Type'] = " text/xml; charset=\"$this->encoding\"";
if (strcasecmp($options['transfer-encoding'],'quoted-printable')==0 ) {
$headers['Content-Transfer-Encoding'] = $options['transfer-encoding'];
} else if (strcasecmp($options['transfer-encoding'],'base64')==0 ) {
$headers['Content-Transfer-Encoding'] = 'base64';
return $this->_raiseSoapFault (" Invalid Transfer Encoding: {$options['transfer-encoding']}" );
$headers['Content-Transfer-Encoding'] = 'base64';
$headers['Subject'] = array_key_exists('subject', $options) ? $options['subject'] : 'SOAP Message';
foreach ($headers as $key => $value) {
$header_text .= " $key: $value\n";
$this->outgoing_payload = $header_text. "\r\n". $this->outgoing_payload;
# we want to return a proper XML message
'username' => $this->username,
'password' => $this->password,
$mailer = & new Mail_smtp ($mailer_params);
$result = $mailer->send ($this->urlparts['path'], $headers, $out);
#$result = mail($this->urlparts['path'], $headers['Subject'], $out, $header_text);
if (!PEAR ::isError ($result)) {
$val = & new SOAP_Value('Message-ID','string',$headers['Message-ID']);
$sval[] = & new SOAP_Value('faultcode','QName','SOAP-ENV:Client');
$sval[] = & new SOAP_Value('faultstring','string'," couldn't send SMTP message to {$this->urlparts['path']}" );
$mqname = & new QName($method, $namespace);
$methodValue = & new SOAP_Value('Response', 'Struct', array ($val));
* set data for http authentication
* creates Authorization header
* @param string $username username
* @param string $password response data, minus http headers
$this->username = $username;
$this->password = $password;
* validate url data passed to constructor
$this->_raiseSoapFault (" Unable to parse URL $url" );
if (!isset ($this->urlparts['scheme']) ||
$this->_raiseSoapFault (" Unable to parse URL $url" );
$this->_raiseSoapFault (" Unable to parse URL $url" );
} // end SOAP_Transport_HTTP
Documentation generated on Mon, 11 Mar 2019 13:59:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|