Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Mail
- {
- public function sendMail($to, $subject, $text, $html)
- {
- $mail = new PHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 3;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'wuwu5431@gmail.com';
- $mail->Password = 'Password';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- //Recipients
- $mail->setFrom('wuwu5431@gmail.com', 'John Smith');
- $mail->addAddress($to, '');
- $mail->addReplyTo('wuwu5431@gmail.com', 'Information($mail->addReplyTo)');
- //Content
- $mail->isHTML(true);
- $mail->Subject = $subject;
- $mail->Body = $text;
- $mail->AltBody = $html . ' $html . This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }//end of method
- }// end of class
- public function sendActivationEmail($email)
- {
- $url = 'url';
- $text = 'text';
- $html = 'html';
- $mail = new AppMail;
- $mail->sendMail($email, 'Account activation', $text, $html);
- }
- public function register()
- {
- if ($_SERVER['REQUEST_METHOD'] == 'POST'){
- $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
- foreach($_POST as $key => $value){
- $data[$key] = htmlspecialchars(strip_tags(trim($value)));
- }
- $this->userModel = new AppModelsUserM;
- if ($this->userModel->Register($data)) {
- Flash::addMessage('Thank you for Registering with us');
- $this->userModel->sendActivationEmail($data['email']);
- $this->redirect('User/UserC/success');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement