function testSendMail() { $dir = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id); $oldmailboxcount = count($dir->getMails()); $data = $this->mail_data; $mail = MailManager::createMail($data); $dir = MailManager::loadDirectoryFromName(MAILBOX, $this->author_id); $newmailboxcount = count($dir->getMails()); //echo "<p>" . $oldmailboxcount . "<br />" . $newmailboxcount . "</p>"; //DEBUG if ($oldmailboxcount == $newmailboxcount) { return "<br />Send test NOT PASSED: not sent"; } return "<br />Send test passed"; }
/** * Se mail == null ne crea una nuova, se mail ha valore quella nuova risponderà a mail. * @param Mail $mail è la mail a cui rispondere. */ static function showNewForm($error = null, $mail = null) { $user = Session::getUser(); if (count($_POST) == 0) { if ($mail == null) { ?> <form name="newmail" action="" method="post"> <fieldset> <legend>New Mail</legend> <?php if ($user != false) { echo "From: <input type=\"text\" name=\"from\" readonly=\"readonly\" value=\"" . $user->getNickName() . "\" />"; } else { echo "From: <input type=\"text\" readonly=\"readonly\" />"; } if (isset($error["from"])) { echo $error["from"]; } ?> <br /> To*: <input type="text" name="to" /> <?php if (isset($error["to"])) { echo $error["to"]; } ?> <br /> Subject: <input type="text" name="subject" /><br /> Text* <?php if (isset($error["text"])) { echo $error["text"]; } ?> <br /> <textarea name="text" rows="8" cols="50"></textarea><br /> <input type="submit" name="send" value="Send" /> </fieldset> </form> <?php } } else { $error = array(); if (isset($_POST["from"]) && $_POST["from"] !== "") { $data["from"] = $user->getID(); } else { $error["from"] = "it's obbligatory!"; } if (isset($_POST["to"]) && $_POST["to"] !== "") { $data["to"] = $_POST["to"]; } else { $error["to"] = "it's obbligatory!"; } if (isset($_POST["subject"])) { $data["subject"] = $_POST["subject"]; } if (isset($_POST["text"]) && $_POST["text"] !== "") { $data["text"] = $_POST["text"]; } else { $error["text"] = "it's obbligatory!"; } if (count($error) > 0) { $_POST = array(); self::showNewForm($error, $mail); } else { MailManager::createMail($data); return true; } } }