Writing SMTP-Based SOAP Messages in PHP
By Shane Caraveo, October 01, 2002
With the buzz around web services, most SOAP usage has focused around the HTTP protocol, but other protocols can be used as well. SMTP has advantages not found with HTTP, including SMTP's ability to store and forward messages, implement one-to-many broadcast messaging, and use attachments to embed extra data into a SOAP message.
October 2002/Writing SMTP-Based SOAP Messages in PHP
Listing 3: Generating the SOAP message in Listing 2
<?php
include("SOAP/Client.php");
/* initialize the SOAP client */
$soapclient = new SOAP_Client('mailto:[email protected]');
/* Decide on the options we want:
for Mime, set 'Mime'=>1
for DIME, set 'DIME'=>1
*/
$options = array(
'namespace'=>'http://domain.com/echoImage',
'from'=>'[email protected]',
'subject' => 'A test SOAP Message',
'host' => 'smtp.domain.com',
'Attachments'=>-Mime-);
/* For most SOAP arguments, PHP variables can be directly passed
without using a wrapper class. However, attachments must be
explicitly wrapped. */
$v = new SOAP_Attachment('inputAttachment','text/plain', 'smtp1.php');
/* In the second argument to the call function below, the array()
could contain multiple arguments if the function accepted them. */
$soapclient->call("echoAttachment",array($v), $options);
?>