25 |
- |
1 |
<?php
|
|
|
2 |
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
3 |
use PHPMailer\PHPMailer\Exception;
|
|
|
4 |
|
|
|
5 |
error_reporting(E_ALL);
|
|
|
6 |
|
65 |
- |
7 |
if (!function_exists('PHPMailer_Init')) {
|
|
|
8 |
function PHPMailer_Init() {
|
|
|
9 |
// Include PHPMailer library files
|
|
|
10 |
require 'PHPMailer/Exception.php';
|
|
|
11 |
require 'PHPMailer/PHPMailer.php';
|
|
|
12 |
require 'PHPMailer/SMTP.php';
|
|
|
13 |
|
|
|
14 |
$mail = new PHPMailer;
|
|
|
15 |
|
|
|
16 |
return $mail;
|
|
|
17 |
}
|
25 |
- |
18 |
}
|
|
|
19 |
|
|
|
20 |
/*
|
|
|
21 |
* Reset new password email sender function
|
65 |
- |
22 |
*/
|
|
|
23 |
if (!function_exists('forgotPassEmail')) {
|
|
|
24 |
function forgotPassEmail($userData) {
|
|
|
25 |
$resetPassLink = BASE_URL . 'resetPassword.php?fp_code=' . $userData['forgot_pass_identity'];
|
25 |
- |
26 |
$to = $userData['email'];
|
74 |
- |
27 |
$subject = "Password Reset Request | " . SITE_NAME;
|
|
|
28 |
$mailContent =
|
|
|
29 |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
30 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
31 |
<head>
|
|
|
32 |
<title>Find Cheap Music Password Reset Request</title>
|
|
|
33 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
34 |
<meta name="viewport" content="width=device-width" />
|
|
|
35 |
</head>
|
|
|
36 |
<body>
|
|
|
37 |
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-radius:6px;background-color:#ffffff;padding-top:15px;border-collapse:separate">
|
|
|
38 |
<tbody>
|
|
|
39 |
<tr>
|
|
|
40 |
<td style="color:#616471;font-weight:400;text-align:left;line-height:190%;padding-top:15px;padding-right:40px;padding-bottom:30px;padding-left:40px;font-size:15px">
|
|
|
41 |
<h1 style="font-weight:500;font-size:22px;letter-spacing:-1px;line-height:115%;margin:18px 0 0;padding:0;text-align:left;color:#3c7bb6">Password Reset Request</h1>
|
|
|
42 |
<br/>
|
|
|
43 |
<p>Recently a request was submitted to reset a password for your account email ' . $to . '. If this was a mistake, just disregard this email and nothing will happen.</p>
|
|
|
44 |
<p>To reset your password, visit the following link:</p>
|
|
|
45 |
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse:collapse">
|
|
|
46 |
<tbody>
|
|
|
47 |
<tr>
|
|
|
48 |
<td align="center" valign="middle" style="padding-top:25px;padding-right:15px;padding-bottom:25px;padding-left:15px">
|
|
|
49 |
<table cellpadding="0" cellspacing="0" border="0" style="border-radius:.25em;background-color:#4582e8;border-collapse:separate">
|
|
|
50 |
<tbody>
|
|
|
51 |
<tr>
|
|
|
52 |
<td align="center" valign="middle" style="border-radius:.25em;background-color:#4582e8;font-weight:400;min-width:180px;font-size:16px;line-height:100%;padding-top:18px;padding-right:30px;padding-bottom:18px;padding-left:30px;color:#ffffff">
|
|
|
53 |
<a href="' . $resetPassLink . '" style="font-weight:500;color:#ffffff;text-decoration:none">Reset Password</a>
|
|
|
54 |
</td>
|
|
|
55 |
</tr>
|
|
|
56 |
</tbody>
|
|
|
57 |
</table>
|
|
|
58 |
</td>
|
|
|
59 |
</tr>
|
|
|
60 |
</tbody>
|
|
|
61 |
</table>
|
|
|
62 |
<p>Let us know at customerservice@FindCheapMusic.com in case of any query or feedback.</p>
|
|
|
63 |
<p>Regards,<br/><strong>' . SITE_NAME . ' Team</strong></p>
|
|
|
64 |
</td>
|
|
|
65 |
</tr>
|
|
|
66 |
</tbody>
|
|
|
67 |
</table>
|
|
|
68 |
</body>
|
|
|
69 |
</html>';
|
25 |
- |
70 |
|
74 |
- |
71 |
$mailContentText = "Recently a request was submitted to reset a password for your account. If this was a mistake, just disregard this email and nothing will happen.\r\n\r\n";
|
25 |
- |
72 |
$mailContentText .= "To reset your password, visit the following link:\r\n\r\n$resetPassLink\r\n\r\n";
|
|
|
73 |
$mailContentText .= "Let us know at customerservice@FindCheapMusic.com in case of any query or feedback.\r\n";
|
|
|
74 |
$mailContentText .= "\r\nRegards,\r\n" . SITE_NAME . " Team";
|
65 |
- |
75 |
|
|
|
76 |
if (SMTP == true) {
|
|
|
77 |
$mail = PHPMailer_Init();
|
|
|
78 |
|
|
|
79 |
// SMTP configuration
|
|
|
80 |
$mail->isSMTP();
|
|
|
81 |
$mail->Host = SMTP_HOST;
|
|
|
82 |
$mail->SMTPAuth = true;
|
|
|
83 |
$mail->Username = SMTP_USERNAME;
|
|
|
84 |
$mail->Password = SMTP_PASSWORD;
|
|
|
85 |
$mail->SMTPSecure = SMTP_SECURE;
|
|
|
86 |
$mail->Port = SMTP_PORT;
|
|
|
87 |
|
|
|
88 |
$mail->setFrom(SENDER_EMAIL, SENDER_NAME);
|
|
|
89 |
|
|
|
90 |
// Add a recipient
|
|
|
91 |
$mail->addAddress($to);
|
|
|
92 |
|
|
|
93 |
// Email subject
|
|
|
94 |
$mail->Subject = $subject;
|
|
|
95 |
|
|
|
96 |
// Set email format to HTML
|
|
|
97 |
$mail->isHTML(true);
|
|
|
98 |
|
|
|
99 |
// Email body content
|
|
|
100 |
$mail->Body = $mailContent;
|
|
|
101 |
$mail->AltBody = $mailContentText;
|
|
|
102 |
|
73 |
- |
103 |
// DKIM
|
|
|
104 |
$mail->DKIM_domain = DKIM_DOMAIN;
|
|
|
105 |
$mail->DKIM_private = $_SERVER['DOCUMENT_ROOT'] . DKIM_PRIVATE;
|
|
|
106 |
$mail->DKIM_selector = DKIM_SELECTOR;
|
|
|
107 |
$mail->DKIM_passphrase = DKIM_PASSPHRASE;
|
|
|
108 |
$mail->DKIM_identity = $mail->From;
|
|
|
109 |
$mail->DKIM_copyHeaderFields = false;
|
|
|
110 |
$mail->DKIM_extraHeaders = ['List-Unsubscribe', 'List-Help'];
|
|
|
111 |
|
65 |
- |
112 |
// Send email
|
|
|
113 |
if (!$mail->send()) {
|
|
|
114 |
error_log('Mailer error: ' . $mail->ErrorInfo);
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
else {
|
|
|
118 |
//set content-type header for sending HTML email
|
|
|
119 |
$headers = "MIME-Version: 1.0" . "\r\n";
|
|
|
120 |
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
|
|
|
121 |
//additional headers
|
|
|
122 |
$headers .= 'From: ' . SENDER_NAME . '<' . SENDER_EMAIL . '>' . "\r\n";
|
|
|
123 |
//send email
|
|
|
124 |
mail($to, $subject, $mailContent, $headers);
|
|
|
125 |
}
|
25 |
- |
126 |
return true;
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
/*
|
|
|
131 |
* Account verification email sender function
|
65 |
- |
132 |
*/
|
|
|
133 |
if (!function_exists('emailVerification')) {
|
|
|
134 |
function emailVerification($userData) {
|
74 |
- |
135 |
$emailVerifyLink = BASE_URL . 'userAccount.php?verifyEmail=1&ac_code=' . $userData['activation_code'];
|
25 |
- |
136 |
$to = $userData['email'];
|
65 |
- |
137 |
$subject = "Please Confirm Your Email | " . SITE_NAME;
|
74 |
- |
138 |
$mailContent =
|
|
|
139 |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
140 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
141 |
<head>
|
|
|
142 |
<title>Find Cheap Music Email Confirmation</title>
|
|
|
143 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
144 |
<meta name="viewport" content="width=device-width" />
|
|
|
145 |
</head>
|
|
|
146 |
<body>
|
|
|
147 |
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-radius:6px;background-color:#ffffff;padding-top:15px;border-collapse:separate">
|
25 |
- |
148 |
<tbody>
|
|
|
149 |
<tr>
|
|
|
150 |
<td style="color:#616471;font-weight:400;text-align:left;line-height:190%;padding-top:15px;padding-right:40px;padding-bottom:30px;padding-left:40px;font-size:15px">
|
|
|
151 |
<h1 style="font-weight:500;font-size:22px;letter-spacing:-1px;line-height:115%;margin:18px 0 0;padding:0;text-align:left;color:#3c7bb6">Email Confirmation</h1>
|
74 |
- |
152 |
<br/>
|
|
|
153 |
Thank you for signing up with Find Cheap Music! Please confirm your email address ' . $to . ' by clicking the link below.
|
|
|
154 |
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse:collapse">
|
25 |
- |
155 |
<tbody>
|
|
|
156 |
<tr>
|
74 |
- |
157 |
<td align="center" valign="middle" style="padding-top:25px;padding-right:15px;padding-bottom:25px;padding-left:15px">
|
|
|
158 |
<table cellpadding="0" cellspacing="0" border="0" style="border-radius:.25em;background-color:#4582e8;border-collapse:separate">
|
25 |
- |
159 |
<tbody>
|
|
|
160 |
<tr>
|
74 |
- |
161 |
<td align="center" valign="middle" style="border-radius:.25em;background-color:#4582e8;font-weight:400;min-width:180px;font-size:16px;line-height:100%;padding-top:18px;padding-right:30px;padding-bottom:18px;padding-left:30px;color:#ffffff">
|
65 |
- |
162 |
<a href="' . $emailVerifyLink . '" style="font-weight:500;color:#ffffff;text-decoration:none">Confirm Email</a>
|
25 |
- |
163 |
</td>
|
|
|
164 |
</tr>
|
|
|
165 |
</tbody>
|
|
|
166 |
</table>
|
|
|
167 |
</td>
|
|
|
168 |
</tr>
|
|
|
169 |
</tbody>
|
|
|
170 |
</table>
|
74 |
- |
171 |
We look forward to serving you,<br/><strong>' . SITE_NAME . ' Team</strong>
|
25 |
- |
172 |
</td>
|
|
|
173 |
</tr>
|
|
|
174 |
</tbody>
|
74 |
- |
175 |
</table>
|
|
|
176 |
</body>
|
|
|
177 |
</html>';
|
25 |
- |
178 |
|
|
|
179 |
$mailContentText = "Thank you for signing up with Find Cheap Music! Please confirm your email address via this link:\r\n\r\n$emailVerifyLink\r\n\r\n";
|
|
|
180 |
$mailContentText .= "\r\nWe look forward to serving you,\r\n" . SITE_NAME . " Team";
|
|
|
181 |
|
65 |
- |
182 |
if (SMTP == true) {
|
|
|
183 |
$mail = PHPMailer_Init();
|
|
|
184 |
|
|
|
185 |
// SMTP configuration
|
|
|
186 |
$mail->isSMTP();
|
|
|
187 |
$mail->CharSet = "text/html; charset=UTF-8;";
|
|
|
188 |
$mail->WordWrap = 80;
|
|
|
189 |
$mail->Host = SMTP_HOST;
|
|
|
190 |
$mail->SMTPAuth = true;
|
|
|
191 |
$mail->Username = SMTP_USERNAME;
|
|
|
192 |
$mail->Password = SMTP_PASSWORD;
|
|
|
193 |
$mail->SMTPSecure = SMTP_SECURE;
|
|
|
194 |
$mail->Port = SMTP_PORT;
|
|
|
195 |
|
|
|
196 |
$mail->setFrom(SENDER_EMAIL, SENDER_NAME);
|
|
|
197 |
|
|
|
198 |
// Add a recipient
|
|
|
199 |
$mail->addAddress($to);
|
|
|
200 |
|
|
|
201 |
// Email subject
|
|
|
202 |
$mail->Subject = $subject;
|
|
|
203 |
|
|
|
204 |
// Set email format to HTML
|
|
|
205 |
$mail->isHTML(true);
|
|
|
206 |
|
|
|
207 |
// Email body content
|
|
|
208 |
$mail->Body = $mailContent;
|
|
|
209 |
$mail->AltBody = $mailContentText;
|
|
|
210 |
|
73 |
- |
211 |
// DKIM
|
|
|
212 |
$mail->DKIM_domain = DKIM_DOMAIN;
|
|
|
213 |
$mail->DKIM_private = $_SERVER['DOCUMENT_ROOT'] . DKIM_PRIVATE;
|
|
|
214 |
$mail->DKIM_selector = DKIM_SELECTOR;
|
|
|
215 |
$mail->DKIM_passphrase = DKIM_PASSPHRASE;
|
|
|
216 |
$mail->DKIM_identity = $mail->From;
|
|
|
217 |
$mail->DKIM_copyHeaderFields = false;
|
|
|
218 |
$mail->DKIM_extraHeaders = ['List-Unsubscribe', 'List-Help'];
|
|
|
219 |
|
65 |
- |
220 |
// Send email
|
|
|
221 |
if (!$mail->send()) {
|
|
|
222 |
error_log('Mailer error: ' . $mail->ErrorInfo);
|
|
|
223 |
}
|
|
|
224 |
}
|
|
|
225 |
else {
|
|
|
226 |
//set content-type header for sending HTML email
|
|
|
227 |
$headers = "MIME-Version: 1.0" . "\r\n";
|
|
|
228 |
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
|
|
|
229 |
//additional headers
|
|
|
230 |
$headers .= 'From: ' . SENDER_NAME . '<' . SENDER_EMAIL . '>' . "\r\n";
|
|
|
231 |
//send email
|
|
|
232 |
mail($to, $subject, $mailContent, $headers);
|
|
|
233 |
}
|
25 |
- |
234 |
return true;
|
|
|
235 |
}
|
31 |
- |
236 |
}
|