Update mailtest.php to show any debug messages
[bugdar.git] / docs / mailtest.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 // runs a few tests to make sure that mailing works
23 // SVN $Id$
24
25 if (!file_exists('./global.php'))
26 {
27 chdir('../');
28 }
29 require_once('./global.php');
30
31 ?>
32 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
33 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
34 <html>
35 <head>
36 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
37 <title>Bugdar: Mail Test</title>
38 </head>
39 <body>
40
41 <h1>Mail Test</h1>
42 <p>This tool will run a few email tests to make sure that emailing works. Follow the instructions below.</p>
43
44 <hr />
45
46 <?php
47
48 if (empty($bugsys->in['__submit__']))
49 {
50 ?>
51
52 <h2>Email Addresses</h2>
53 <p><strong>Enter in the following email addresses for sending and receiving.</strong></p>
54
55 <form action="mailtest.php" method="get" accept-charset="utf-8">
56 <p>Email address to <em>receieve</em> all tests: <input type="text" name="receive" value="" size="25" /></p>
57 <p>An email address that exists on the mail server that is <em>not</em> the one receiving the tests: <input type="text" name="sender" value="" size="25 /"></p>
58 <p><input type="submit" name="__submit__" value="Continue &rarr;"></p>
59 </form>
60
61 <?php
62 }
63 else
64 {
65 $text = "You have successfully received test %d of 4. This tests %s.
66
67 ###################################################################
68 PHP: " . phpversion() . "
69 Mail Test: " . '$Revision$' . "
70 Sendmail (From): \"" . ini_get('sendmail_from') . "\"
71 Sendmail (Path): \"" . ini_get('sendmail_path') . "\"";
72
73 $mail->setFromName('Bugdar Mailing Test');
74 $mail->setSubject('Email Tests');
75
76 if (empty($bugsys->in['receive']) OR empty($bugsys->in['sender']) OR !$funct->is_valid_email($bugsys->in['receive']) OR !$funct->is_valid_email($bugsys->in['sender']))
77 {
78 echo '<p style="color: red">You did not fill in all the fields or the email addresses are not valid. Please <a href="mailtest.php">go back</a>.</p>';
79 }
80 else
81 {
82 // normal Bugdar mailing
83 $mail->setBodyText(sprintf($text, 1, 'sending with the Bugdar-configured address'));
84 $mail->send($bugsys->in['receive']);
85
86 // mail from the alternate address
87 $mail->setBodyText(sprintf($text, 2, 'sending from the address you specified that exists on the mail server'));
88 $mail->setFromAddress($bugsys->in['sender']);
89 $mail->send($bugsys->in['receive']);
90
91 // mail from self
92 $mail->setBodyText(sprintf($text, 3, 'sending from the receiving address'));
93 $mail->setFromAddress($bugsys->in['receive']);
94 $mail->send($bugsys->in['receive']);
95
96 // mail from non-existent
97 $mail->setBodyText(sprintf($text, 4, 'sending from a non-existent address'));
98 $mail->setFromAddress(preg_replace('#(.*)@(.*)#', 'bugdar-mail-test@\2', $bugsys->in['receive']));
99 $mail->send($bugsys->in['receive']);
100
101 ?>
102
103 <h2>Complete</h2>
104 <p>All the test emails were sent to <em><?= $bugsys->in['receive'] ?></em>. Please check that you received all 4 tests.</p>
105
106 <?php
107 }
108 }
109
110 ?>
111
112 <hr />
113
114 <h2>Variables</h2>
115 <p>
116 <div>PHP: <?php echo phpversion(); ?></div>
117 <div>Mail Test: $Revision$</div>
118 <div>Sendmail (From): "<?php echo ini_get('sendmail_from'); ?>"</div>
119 <div>Sendmail (Path): "<?php echo ini_get('sendmail_path'); ?>"</div>
120 <div>Debug Messages: <pre><?php print_r($bugsys->debuginfo) ?></pre></div>
121 </p>
122
123 </body>
124 </html>
125 <?php
126
127 /*=====================================================================*\
128 || ###################################################################
129 || # $HeadURL$
130 || # $Id$
131 || ###################################################################
132 \*=====================================================================*/
133 ?>