function recover($mail) { $dao = new UserDAO(); $id = $dao->getUserIdByMail($mail); if ($id != -1) { $user = $dao->selectUserById($id); $name = $user->getName(); $pass = $user->getPassword(); $message = "Dear " . $name . ", Your account password is " . $pass; $subject = "Password Recovery Mail"; $mailSender = new MailSender(); $mailSender->sendMail("*****@*****.**", $mail, $message, $subject); } return $id; }
<?php namespace Qnet\Controller; require_once dirname(__FILE__) . '\\..\\util.php'; require_service("mailer/swift_required"); require_service("MailSender"); use Qnet\Service\MailSender; $subject = "Join Qnet!"; $content = "Sent you an invitation to join Qnet, the best Query networking site! http://localhost/Qnet/target/classes/php/qnet"; $to = $_POST['friend_mail']; $mailSender = new MailSender(); $mailSender->sendMail("*****@*****.**", $to, $content, $subject); header("Location: /Qnet/target/classes/php/qnet/ui/viewprofile.php?recommend=ok");