예제 #1
0
function sendForgotPasswordMail($user, $password, $config)
{
    $message = "Your password to log into WildVapor has been\n    temporarily changed to '{$password}'. Please log in using that password and this\n    email address. Then you may change your password to something more familiar.";
    if ($config['live']) {
        $body = file_get_contents(BASE_URI . DS . 'views' . DS . 'mail_template.html');
        $body = str_replace('{{title}}', 'Your temporary password at WildVapor Inc', $body);
        $body = str_replace('{{message}}', $message, $body);
        $data = array('live' => $config['live'], 'mail_username' => $config['mail_username'], 'mail_password' => $config['mail_password'], 'mail_to_address' => $user['email'], 'mail_to_name' => \Helpers\User::get_name($user), 'subject' => 'Your temporary password at WildVapor.', 'body' => $body, 'mail_from' => $config['mail_from']);
        $mailer = new \Helpers\Mailer($data);
        if ($mailer->sendMail()) {
            return 'Your password has been changed. You will receive
        the new, temporary password via email. Once you have logged in
        with this new password, you may change it by clicking on the "Change
        Password" link.';
        } else {
            return array('error' => $mailer->getError());
        }
    } else {
        return $message;
    }
}