blob: 61efb2f80b40401ddcaa7cb10d0fed72cf33c2c9 (
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
59
60
61
62
63
64
65
66
67
68
69
70
|
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class Form
{
public $name;
public $email;
public $message;
public $spam;
public function spam()
{
if ((bool) $this->spam == true) {
error_log('Contact Form Spam: Error 403');
return true;
}
}
public function empty()
{
if ((bool) empty($this->email) == true
|| (bool) empty($this->message) == true
) {
return true;
}
}
public function emailValid()
{
return $email = PHPMailer::validateAddress($this->email, 'auto');
}
public function submit()
{
// Include 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'], 'Thedro Neely');
$mail->addAddress($config['mail']['username'], 'Thedro Neely');
//Content
$mail->isHTML(true);
$mail->Subject = 'New message from ' . $this->email;
$mail->Body = $this->message . "\n\n" . $this->name . "\n" . $this->email;
$mail->AltBody = $this->message . "\n\n" . $this->name . "\n" . $this->email;
//Send Mail
$mail->send();
} catch (Exception $exception) {
log_exception($exception);
}
}
}
|