Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / 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.
14     When you press <kbd>Send</kbd> this page will reload, showing you the XML-RPC request sent to the host server, the
15     XML-RPC response received and the internal evaluation done by the PHP implementation.</p>
16
17 <p>You can find the source to this page here: <a href="mail.php?showSource=1">mail.php</a><br/>
18     And the source to a functionally identical mail-by-XML-RPC server in the file <a
19         href="../server/server.php?showSource=1">server.php</a> included with the library (look for the 'mail_send'
20     method)</p>
21 <?php
22
23 include_once __DIR__ . "/../../src/Autoloader.php";
24 PhpXmlRpc\Autoloader::register();
25
26 if (isset($_POST["mailto"]) && $_POST["mailto"]) {
27     $server = "http://phpxmlrpc.sourceforge.net/server.php";
28     $req = new PhpXmlRpc\Request('mail.send', array(
29         new PhpXmlRpc\Value($_POST["mailto"]),
30         new PhpXmlRpc\Value($_POST["mailsub"]),
31         new PhpXmlRpc\Value($_POST["mailmsg"]),
32         new PhpXmlRpc\Value($_POST["mailfrom"]),
33         new PhpXmlRpc\Value($_POST["mailcc"]),
34         new PhpXmlRpc\Value($_POST["mailbcc"]),
35         new PhpXmlRpc\Value("text/plain")
36     ));
37
38     $client = new PhpXmlRpc\Client($server);
39     $client->setDebug(2);
40     $resp = $client->send($req);
41     if (!$resp->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($resp->faultCode()) .
48             " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>";
49         print "</font><br/>";
50     }
51 }
52 ?>
53 <form method="POST">
54     From <input size="60" name="mailfrom" value=""/><br/>
55     <hr/>
56     To <input size="60" name="mailto" value=""/><br/>
57     Cc <input size="60" name="mailcc" value=""/><br/>
58     Bcc <input size="60" name="mailbcc" value=""/><br/>
59     <hr/>
60     Subject <input size="60" name="mailsub" value="A message from xmlrpc"/>
61     <hr/>
62     Body <textarea rows="7" cols="60" name="mailmsg">Your message here</textarea><br/>
63     <input type="Submit" value="Send"/>
64 </form>
65 </body>
66 </html>