(Guillermo) Add-email-sender-class
This commit is contained in:
parent
0093a24faa
commit
fad653ed7b
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"slim/slim": "~2.0",
|
"slim/slim": "~2.0",
|
||||||
"gabordemooij/redbean": "~4.2"
|
"gabordemooij/redbean": "~4.2",
|
||||||
|
"phpmailer/phpmailer": "^5.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "5.0.*"
|
"phpunit/phpunit": "5.0.*"
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
class SignUpController extends Controller {
|
class SignUpController extends Controller {
|
||||||
const PATH = '/signup';
|
const PATH = '/signup';
|
||||||
|
|
||||||
|
private $email;
|
||||||
|
private $password;
|
||||||
|
|
||||||
public function handler() {
|
public function handler() {
|
||||||
$email = Controller::request('email');
|
$this->requestUserData();
|
||||||
$password = Controller::request('password');
|
|
||||||
|
|
||||||
$userId = $this->createNewUserAndRetrieveId($email, $password);
|
$userId = $this->createNewUserAndRetrieveId($email, $password);
|
||||||
|
|
||||||
|
@ -13,6 +15,12 @@ class SignUpController extends Controller {
|
||||||
'userId' => $userId,
|
'userId' => $userId,
|
||||||
'userEmail' => $email
|
'userEmail' => $email
|
||||||
));
|
));
|
||||||
|
|
||||||
|
EmailSender::validRegister($email);
|
||||||
|
}
|
||||||
|
public function requestUserData(){
|
||||||
|
$this->email = Controller::request('email');
|
||||||
|
$this->password = Controller::request('password');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createNewUserAndRetrieveId($email, $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