(Guillermo) Add-email-sender-class
This commit is contained in:
parent
0093a24faa
commit
fad653ed7b
|
@ -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.*"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue