aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/Functions.php
blob: 47008c33ddfc7c732f9c7c7e4e377a03feff1425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

// PHP mailer namespace.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

function sendMail($name, $email, $message)
{
    // Require mail config
    $config = include '../AppConfig.php';

    $mail = new PHPMailer(true);
    try {
        //Server settings
        //$mail->SMTPDebug = 2;
        $mail->isSMTP();
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = 'ssl';
        $mail->Port = $config['mail']['port'];
        $mail->Host = $config['mail']['host'];
        $mail->Username = $config['mail']['username'];
        $mail->Password = $config['mail']['password'];

        //Recipients
        $mail->setFrom($config['mail']['username'], $config['mail']['name']);
        $mail->addAddress($config['mail']['username'], $config['mail']['name']);

        //Content
        $mail->isHTML(true);
        $mail->Subject = 'New message from ' . $email;
        $mail->Body    = $message . "\n\n" . $name . "\n" . $email;
        $mail->AltBody = $message . "\n\n" . $name . "\n" . $email;

        $mail->send();

    } catch (Exception $exception) {
        log_exception($exception);
    }
}

function title()
{
    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';
    }
}