merge upstream phpxmlrpc
[plcapi.git] / php / phpxmlrpc / demo / client / mail.php
1 <?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
2 <head><title>xmlrpc - Mail demo</title></head>
3 <body>
4 <h1>Mail demo</h1>
5
6 <p>This form enables you to send mail via an XML-RPC server.
7     When you press <kbd>Send</kbd> this page will reload, showing you the XML-RPC request sent to the host server, the
8     XML-RPC response received and the internal evaluation done by the PHP implementation.</p>
9
10 <p>You can see the source to this page here: <a href="mail.php?showSource=1">mail.php</a><br/>
11     And the source to a functionally identical mail-by-XML-RPC server in the file <a
12         href="../server/server.php?showSource=1">server.php</a> included with the library (look for the 'mail_send'
13     method)</p>
14 <?php
15
16 if (isset($_POST["mailto"]) && $_POST["mailto"]) {
17     $server = XMLRPCSERVER;
18     $req = new PhpXmlRpc\Request('mail.send', array(
19         new PhpXmlRpc\Value($_POST["mailto"]),
20         new PhpXmlRpc\Value($_POST["mailsub"]),
21         new PhpXmlRpc\Value($_POST["mailmsg"]),
22         new PhpXmlRpc\Value($_POST["mailfrom"]),
23         new PhpXmlRpc\Value($_POST["mailcc"]),
24         new PhpXmlRpc\Value($_POST["mailbcc"]),
25         new PhpXmlRpc\Value("text/plain")
26     ));
27
28     $client = new PhpXmlRpc\Client($server);
29     $client->setDebug(2);
30     $resp = $client->send($req);
31     if (!$resp->faultCode()) {
32         print "Mail sent OK<br/>\n";
33     } else {
34         print "<font color=\"red\">";
35         print "Mail send failed<br/>\n";
36         print "Fault: ";
37         print "Code: " . htmlspecialchars($resp->faultCode()) .
38             " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>";
39         print "</font><br/>";
40     }
41 }
42 ?>
43 <form method="POST">
44     From <input size="60" name="mailfrom" value=""/><br/>
45     <hr/>
46     To <input size="60" name="mailto" value=""/><br/>
47     Cc <input size="60" name="mailcc" value=""/><br/>
48     Bcc <input size="60" name="mailbcc" value=""/><br/>
49     <hr/>
50     Subject <input size="60" name="mailsub" value="A message from xmlrpc"/>
51     <hr/>
52     Body <textarea rows="7" cols="60" name="mailmsg">Your message here</textarea><br/>
53     <input type="Submit" value="Send"/>
54 </form>
55 </body>
56 </html><?php require_once __DIR__ . "/_append.php"; ?>