(Guillermo) Add-email-sender-class

This commit is contained in:
AntonyAntonio 2016-07-04 04:09:32 -03:00
parent 0093a24faa
commit fad653ed7b
3 changed files with 33 additions and 3 deletions

View File

@ -1,7 +1,8 @@
{
"require": {
"slim/slim": "~2.0",
"gabordemooij/redbean": "~4.2"
"gabordemooij/redbean": "~4.2",
"phpmailer/phpmailer": "^5.2"
},
"require-dev": {
"phpunit/phpunit": "5.0.*"

View File

@ -3,9 +3,11 @@
class SignUpController extends Controller {
const PATH = '/signup';
private $email;
private $password;
public function handler() {
$email = Controller::request('email');
$password = Controller::request('password');
$this->requestUserData();
$userId = $this->createNewUserAndRetrieveId($email, $password);
@ -13,6 +15,12 @@ class SignUpController extends Controller {
'userId' => $userId,
'userEmail' => $email
));
EmailSender::validRegister($email);
}
public function requestUserData(){
$this->email = Controller::request('email');
$this->password = Controller::request('password');
}
public function createNewUserAndRetrieveId($email, $password) {

View File

@ -0,0 +1,21 @@
<?php
class EmailSender {
public function validRegister($mail) {
$newMail = new PHPMailer;
$newMail->addAddress($mail);
$newMail->Subject = "You Have Been register successfully";
if(!$newMail->send())
{
echo "Mailer Error: " . $newMail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
}
}