/** * @function * @public * @static * @returns NONE * @desc * @param {string} foo Use the 'foo' param for bar. * @example NONE */ public static function sendVerificationEmail($user_id, $user_email, $user_activation_hash) { return true; $body = Config::get('EMAIL_VERIFICATION_CONTENT') . Config::get('URL') . Config::get('EMAIL_VERIFICATION_URL') . '/' . urlencode($user_id) . '/' . urlencode($user_activation_hash); $mail = new Mail(); $mail_sent = $mail->sendMail($user_email, Config::get('EMAIL_VERIFICATION_FROM_EMAIL'), Config::get('EMAIL_VERIFICATION_FROM_NAME'), Config::get('EMAIL_VERIFICATION_SUBJECT'), $body); if ($mail_sent) { Session::add('feedback_positive', Text::get('FEEDBACK_VERIFICATION_MAIL_SENDING_SUCCESSFUL')); return true; } else { Session::add('feedback_negative', Text::get('FEEDBACK_VERIFICATION_MAIL_SENDING_ERROR') . $mail->getError()); return false; } }
public function forgotPasswordAction($db, $posted) { $count = $db->query("SELECT COUNT(*) FROM sent_emails WHERE email_address = \n :email_address AND timestamp >= :time", array(':email_address' => $posted['hash'], ':time' => $posted['time_formatted'])); $exists = self::get_user_by_email($db, $posted['email']); if (!$exists) { return "User Doesn't Exist"; } if (count($count) < 10) { $deactivation_stmt = $db->update("responses", array('active' => 0), array('email_address' => $posted['email']), array()); $password_token = Password::rnum(); $toBePosted = []; $toBePosted['reset_key'] = Password::rnum(); $toBePosted['secret'] = Password::make($password_token, PASSWORD_BCRYPT, array("cost" => 10)); $toBePosted['request_timestamp'] = date('Y-m-d H:i:s'); $toBePosted['request_ip'] = getenv('REMOTE_ADDR'); $toBePosted['email_address'] = $posted['email']; $result = $db->insert("responses", $toBePosted, array()); $mail_to = $posted['email']; $mail_subject = 'Reset password'; $mail_body = "Hello, \n <br><br> \n you or somebody else requested a password reset for your account at Acadia Robotics. \n <br><br> \n To set a new password, please visit this link: \n <br><br> \n http://robots-old.acadiau.ca/registration/#/reset_password?reset_key=" . $toBePosted['reset_key'] . "&email=" . $toBePosted['email_address'] . "&password_token=" . $password_token . " \n <br><br> \n Do not share this link with anyone, it expires in 30 minutes. \n <br><br> \n If the request was not from you (or not intended for you), simply ignore this email. Your password will not be changed. \n <br><br> \n Do you have further questions? Please contact us at robots@acadiau.ca. \n <br><br> \n Best regards, \n <br><br> \n robots.acadiau.ca"; $mail = new Mail(); $mail_sent = $mail->sendMail($mail_to, "www-data@localhost", "ACCOUNT ", $mail_subject, $mail_body); if ($mail_sent == 1) { $new_stmt = $db->exec('INSERT INTO sent_emails (email_address, timestamp) VALUES (:email_address, NOW())', array(':email_address' => $posted['hash'])); return "Mail Sent!"; } else { return "Mail not sent" . $mail->getError(); } } }
/** * Send the password reset mail * * @param string $user_name username * @param string $user_password_reset_hash password reset hash * @param string $user_email user email * * @return bool success status */ public static function sendPasswordResetMail($user_name, $user_password_reset_hash, $user_email) { // create email body $body = Config::get('EMAIL_PASSWORD_RESET_CONTENT') . ' ' . URL . Config::get('EMAIL_PASSWORD_RESET_URL') . '/' . urlencode($user_name) . '/' . urlencode($user_password_reset_hash); // create instance of Mail class, try sending and check $mail = new Mail(); $mail_sent = $mail->sendMail($user_email, Config::get('EMAIL_PASSWORD_RESET_FROM_EMAIL'), Config::get('EMAIL_PASSWORD_RESET_FROM_NAME'), Config::get('EMAIL_PASSWORD_RESET_SUBJECT'), $body); if ($mail_sent) { Session::add('feedback_positive', Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_SUCCESSFUL')); return true; } Session::add('feedback_negative', Text::get('FEEDBACK_PASSWORD_RESET_MAIL_SENDING_ERROR') . $mail->getError()); return false; }
public static function sendVerificationEmail($user_id, $user_email, $user_activation_verification_code) { $body = 'Por favor, haga clic en este enlace para desbloquear tu cuenta: ' . Config::get('URL') . 'login/verifyUserBlocked' . '/' . urlencode($user_id) . '/' . urlencode($user_activation_verification_code); $mail = new Mail(); $mail_sent = $mail->sendMail($user_email, Config::get('EMAIL_VERIFICATION_FROM_EMAIL'), Config::get('EMAIL_VERIFICATION_FROM_NAME'), 'Desbloqueo de su cuenta de ADV Trabajos Verticales', $body); if ($mail_sent) { Session::add('feedback_positive', Text::get('FEEDBACK_VERIFICATION_MAIL_SENDING_SUCCESSFUL')); return true; } else { Session::add('feedback_negative', Text::get('FEEDBACK_VERIFICATION_MAIL_SENDING_ERROR') . $mail->getError()); return false; } }