e1966b38dd3eb708acea676bfc8b9f8f70791966
[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($_GET['showSource']) && $_GET['showSource']) {
4     highlight_file(__FILE__);
5     die();
6 }
7 ?>
8 <html>
9 <head><title>xmlrpc - Mail demo</title></head>
10 <body>
11 <h1>Mail demo</h1>
12
13 <p>This form enables you to send mail via an XML-RPC server. For public use
14     only the "Userland" server will work (see <a href="http://www.xmlrpc.com/discuss/msgReader$598">Dave Winer's
15         message</a>).
16     When you press <kbd>Send</kbd> this page will reload, showing you the XML-RPC request sent to the host server, the
17     XML-RPC response received and the internal evaluation done by the PHP implementation.</p>
18
19 <p>You can find the source to this page here: <a href="mail.php?showSource=1">mail.php</a><br/>
20     And the source to a functionally identical mail-by-XML-RPC server in the file <a
21         href="../server/server.php?showSource=1">server.php</a> included with the library (look for the 'mail_send'
22     method)</p>
23 <?php
24
25 include_once __DIR__ . "/../../src/Autoloader.php";
26 PhpXmlRpc\Autoloader::register();
27
28 if (isset($_POST["server"]) && $_POST["server"]) {
29     if ($_POST["server"] == "Userland") {
30         $server = "http://206.204.24.2/RPC2";
31     } else {
32         $server = "http://pingu.heddley.com/xmlrpc/server.php";
33     }
34     $req = new PhpXmlRpc\Request('mail.send', array(
35         new PhpXmlRpc\Value($_POST["mailto"]),
36         new PhpXmlRpc\Value($_POST["mailsub"]),
37         new PhpXmlRpc\Value($_POST["mailmsg"]),
38         new PhpXmlRpc\Value($_POST["mailfrom"]),
39         new PhpXmlRpc\Value($_POST["mailcc"]),
40         new PhpXmlRpc\Value($_POST["mailbcc"]),
41         new PhpXmlRpc\Value("text/plain")
42     ));
43
44     $client = new PhpXmlRpc\Client($server);
45     $client->setDebug(2);
46     $resp = $client->send($req);
47     if (!$resp->faultCode()) {
48         print "Mail sent OK<br/>\n";
49     } else {
50         print "<fonr color=\"red\">";
51         print "Mail send failed<br/>\n";
52         print "Fault: ";
53         print "Code: " . htmlspecialchars($resp->faultCode()) .
54             " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>";
55         print "</font><br/>";
56     }
57 }
58 ?>
59 <form method="POST">
60     Server <select name="server">
61         <option value="Userland">Userland</option>
62         <option value="UsefulInc">UsefulInc private server</option>
63     </select>
64     <hr/>
65     From <input size="60" name="mailfrom" value=""/><br/>
66     <hr/>
67     To <input size="60" name="mailto" value=""/><br/>
68     Cc <input size="60" name="mailcc" value=""/><br/>
69     Bcc <input size="60" name="mailbcc" value=""/><br/>
70     <hr/>
71     Subject <input size="60" name="mailsub" value="A message from xmlrpc"/>
72     <hr/>
73     Body <textarea rows="7" cols="60" name="mailmsg">Your message here</textarea><br/>
74     <input type="Submit" value="Send"/>
75 </form>
76 </body>
77 </html>