More tabs/to/spaces conversion, plus remove closing php tags as they are not consider...
[plcapi.git] / demo / client / mail.php
1 <?php
2 // Allow users to see the source of this file even if PHP is not configured for it
3 if ((isset($HTTP_GET_VARS['showSource']) && $HTTP_GET_VARS['showSource']) ||
4     (isset($_GET['showSource']) && $_GET['showSource']))
5     { highlight_file(__FILE__); die(); }
6 ?>
7 <html>
8 <head><title>xmlrpc</title></head>
9 <body>
10 <h1>Mail demo</h1>
11 <p>This form enables you to send mail via an XML-RPC server. For public use
12 only the "Userland" server will work (see <a href="http://www.xmlrpc.com/discuss/msgReader$598">Dave Winer's message</a>).
13 When you press <kbd>Send</kbd> this page will reload, showing you the XML-RPC request sent to the host server, the XML-RPC response received and the internal evaluation done by the PHP implementation.</p>
14 <p>You can find the source to this page here: <a href="mail.php?showSource=1">mail.php</a><br/>
15 And the source to a functionally identical mail-by-XML-RPC server in the file <a href="../server/server.php?showSource=1">server.php</a> included with the library (look for the 'mail_send' method)</p>
16 <?php
17 include("xmlrpc.inc");
18
19 // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
20 if (!isset($HTTP_POST_VARS) && isset($_POST))
21     $HTTP_POST_VARS = $_POST;
22
23 if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) {
24     if ($HTTP_POST_VARS["server"]=="Userland") {
25         $XP="/RPC2"; $XS="206.204.24.2";
26     } else {
27         $XP="/xmlrpc/server.php"; $XS="pingu.heddley.com";
28     }
29     $f=new xmlrpcmsg('mail.send');
30     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailto"]));
31     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailsub"]));
32     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailmsg"]));
33     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailfrom"]));
34     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailcc"]));
35     $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailbcc"]));
36     $f->addParam(new xmlrpcval("text/plain"));
37
38     $c=new xmlrpc_client($XP, $XS, 80);
39     $c->setDebug(2);
40     $r=&$c->send($f);
41     if (!$r->faultCode()) {
42         print "Mail sent OK<br/>\n";
43     } else {
44         print "<fonr color=\"red\">";
45         print "Mail send failed<br/>\n";
46         print "Fault: ";
47         print "Code: " . htmlspecialchars($r->faultCode()) .
48       " Reason: '" . htmlspecialchars($r->faultString()) . "'<br/>";
49         print "</font><br/>";
50     }
51 }
52 ?>
53 <form method="POST">
54 Server <select name="server"><option value="Userland">Userland</option>
55 <option value="UsefulInc">UsefulInc private server</option></select>
56 <hr/>
57 From <input size="60" name="mailfrom" value=""/><br/>
58 <hr/>
59 To <input size="60" name="mailto" value=""/><br/>
60 Cc <input size="60" name="mailcc" value=""/><br/>
61 Bcc <input size="60" name="mailbcc" value=""/><br/>
62 <hr/>
63 Subject <input size="60" name="mailsub" value="A message from xmlrpc"/>
64 <hr/>
65 Body <textarea rows="7" cols="60" name="mailmsg">Your message here</textarea><br/>
66 <input type="Submit" value="Send"/>
67 </form>
68 <hr/>
69 <em>$Id$</em>
70 </body>
71 </html>