-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
110 lines (90 loc) · 3.65 KB
/
mail.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
require_once 'connect.php';
//Phpmailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once __DIR__ . '/vendor/autoload.php';
// Output messages
$responses = [];
//Data Sanitization and protection from SQL Injection Attack
$email = isset($_POST["email"]) ? htmlspecialchars($_POST["email"]) : '';
// Check if the form was submitted
if (isset($email)) {
// Validate email adress
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$responses[] = 'Email is not valid!';
}
// Make sure the form fields are not empty
if (empty($email)) {
$responses[] = 'Please complete all fields!';
}
// If there are no errors
if (!$responses) {
// Prepare the SQL query with placeholders
$stmt = $pdo->prepare("INSERT INTO subscribers_details (email_address) VALUES (:email)");
// Bind the form data to the placeholders
$stmt->bindParam(':email', $email);
// Execute the query
try {
$stmt->execute();
echo "Record inserted successfully.";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
try {
//Server Settings
$phpmailer = new PHPMailer(true);
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.titan.email';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = 'info@xauman.com';
$phpmailer->Password = 'traderjosh@2023';
$phpmailer->setFrom('info@xauman.com', 'Xauman Forex');
$phpmailer->addReplyTo($email, 'Sender Details');
$phpmailer->addAddress($email, 'Commodities Trader');
//SMTP Debug Setting
$phpmailer->SMTPDebug = 0;
//Email Sender & Subject
$phpmailer->Sender = 'info@xauman.com';
$phpmailer->Subject = "Welcome to Xauman Forex!";
//Read the contents of the html file
$htmlcontent = file_get_contents('email/xauman_email.html');
// Enable HTML if needed
$phpmailer->isHTML(true);
$phpmailer->Body = $htmlcontent;
$phpmailer->send();
} catch (Exception $exception) {
$errorMessage = 'Oops, something went wrong. Mailer Error: ' . $exception->errorMessage();
}
try {
//Server Settings
$phpmailer = new PHPMailer(true);
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.titan.email';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = 'info@xauman.com';
$phpmailer->Password = 'traderjosh@2023';
$phpmailer->setFrom('info@xauman.com', 'Xauman Forex');
$phpmailer->addReplyTo('info@xauman.com', 'Sender Details');
$phpmailer->addAddress('info@xauman.com', 'Administrator');
$phpmailer->addBCC('muhindablasio@gmail.com', 'Administrator');
//SMTP Debug Setting
$phpmailer->SMTPDebug = 0;
//Email Sender & Subject
$phpmailer->Sender = 'info@xauman.com';
$phpmailer->Subject = "New User Registered with Us";
$body = file_get_contents('email/admin_notification.html');
// Enable HTML if needed
$phpmailer->isHTML(true);
$phpmailer->Body = $body;
$phpmailer->send();
} catch (Exception $exception) {
$errorMessage = 'Oops, something went wrong. Mailer Error: ' . $exception->errorMessage();
}
}
}
?>