diff options
Diffstat (limited to 'bootstrap/Functions.php')
-rw-r--r-- | bootstrap/Functions.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/bootstrap/Functions.php b/bootstrap/Functions.php new file mode 100644 index 0000000..2308f9b --- /dev/null +++ b/bootstrap/Functions.php @@ -0,0 +1,58 @@ +<?php + +// PHP mailer namespace. +use PHPMailer\PHPMailer\PHPMailer; +use PHPMailer\PHPMailer\Exception; + +function sendMail($name, $email, $message) +{ + // Require mail config + $config = require '../AppConfig.php'; + + $mail = new PHPMailer(true); + try { + //Server settings + //$mail->SMTPDebug = 2; // Enable verbose debug output + $mail->isSMTP(); // Set mailer to use SMTP + $mail->Host = $config['mail']['host']; // Specify main and backup SMTP servers + $mail->SMTPAuth = true; // Enable SMTP authentication + $mail->Username = $config['mail']['username']; // SMTP username + $mail->Password = $config['mail']['password']; // SMTP password + $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted + $mail->Port = $config['mail']['port']; // TCP port to connect to + + //Recipients + $mail->setFrom('edwinmattiacci@yahoo.com', 'Edwin Mattiacci'); + $mail->addAddress('edwinmattiacci@yahoo.com', 'Edwin Mattiacci'); + $mail->addReplyTo($email, $name); + + //Content + $mail->isHTML(true); + $mail->Subject = 'New message from ' . $name; + $mail->Body = $message; + $mail->AltBody = $message; + + $mail->send(); + } catch (Exception $e) { + require '../views/senterror.view.php'; + } +} + +function webTitle() +{ + switch ($_SERVER['REQUEST_URI']) { + case '/feedback/': + $uri = $_SERVER['REQUEST_URI']; + echo $titleHeader = 'Feedback'; + break; + + case '/contact/': + $uri = $_SERVER['REQUEST_URI']; + echo $titleHeader = 'Contact'; + break; + + default: + $uri = '/'; + echo $titleHeader = 'Voiceover'; + } +} |