| 25 |
- |
1 |
<?php
|
|
|
2 |
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
3 |
use PHPMailer\PHPMailer\Exception;
|
|
|
4 |
|
|
|
5 |
ini_set("log_errors", 1);
|
| 31 |
- |
6 |
ini_set("error_log", $_SERVER['DOCUMENT_ROOT'] . "/../MyFiles/logs/php_error.log");
|
| 25 |
- |
7 |
error_reporting(E_ALL);
|
|
|
8 |
|
|
|
9 |
if(! function_exists('PHPMailer_Init')){
|
|
|
10 |
function PHPMailer_Init(){
|
|
|
11 |
// Include PHPMailer library files
|
|
|
12 |
require 'PHPMailer/Exception.php';
|
|
|
13 |
require 'PHPMailer/PHPMailer.php';
|
|
|
14 |
require 'PHPMailer/SMTP.php';
|
|
|
15 |
|
|
|
16 |
$mail = new PHPMailer;
|
|
|
17 |
|
|
|
18 |
return $mail;
|
|
|
19 |
}
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
/*
|
|
|
23 |
* Reset new password email sender function
|
|
|
24 |
*/
|
|
|
25 |
if(! function_exists('forgotPassEmail')){
|
|
|
26 |
function forgotPassEmail($userData){
|
|
|
27 |
$resetPassLink = BASE_URL.'resetPassword.php?fp_code='.$userData['forgot_pass_identity'];
|
|
|
28 |
$to = $userData['email'];
|
|
|
29 |
$subject = "Password Update Request | ".SITE_NAME;
|
|
|
30 |
$mailContent = '<html><head><title>Find Cheap Music Password Update Request</title>
|
|
|
31 |
</head>
|
|
|
32 |
<body><p>Dear ' . $userData['first_name'] . ',</p>
|
|
|
33 |
<p>Recently a request was submitted to reset a password for your account. If this was a mistake, just ignore this email and nothing will happen.</p>
|
|
|
34 |
<p>To reset your password, visit the following link:</p>
|
|
|
35 |
<table border="0" cellpadding="0" cellspacing="0" style="border-radius:.25em;background-color:#4582e8;border-collapse:separate">
|
|
|
36 |
<tbody>
|
|
|
37 |
<tr>
|
|
|
38 |
<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">
|
|
|
39 |
<a href="'.$resetPassLink.'" style="font-weight:500;color:#ffffff;text-decoration:none">Reset Password</a>
|
|
|
40 |
</td>
|
|
|
41 |
</tr>
|
|
|
42 |
</tbody>
|
|
|
43 |
</table>
|
|
|
44 |
<p>Let us know at customerservice@FindCheapMusic.com in case of any query or feedback.</p>
|
|
|
45 |
<p>Regards,<br/><strong>'.SITE_NAME.' Team</strong></p></body></html>';
|
|
|
46 |
|
|
|
47 |
$mailContentText = "Dear " . $userData['first_name'] . ",\r\n\r\n";
|
|
|
48 |
$mailContentText .= "Recently a request was submitted to reset a password for your account. If this was a mistake, just ignore this email and nothing will happen.\r\n\r\n";
|
|
|
49 |
$mailContentText .= "To reset your password, visit the following link:\r\n\r\n$resetPassLink\r\n\r\n";
|
|
|
50 |
$mailContentText .= "Let us know at customerservice@FindCheapMusic.com in case of any query or feedback.\r\n";
|
|
|
51 |
$mailContentText .= "\r\nRegards,\r\n" . SITE_NAME . " Team";
|
|
|
52 |
|
|
|
53 |
|
| 35 |
- |
54 |
if(SMTP == true){
|
| 25 |
- |
55 |
$mail = PHPMailer_Init();
|
|
|
56 |
|
|
|
57 |
// SMTP configuration
|
|
|
58 |
$mail->isSMTP();
|
|
|
59 |
$mail->Host = SMTP_HOST;
|
|
|
60 |
$mail->SMTPAuth = true;
|
|
|
61 |
$mail->Username = SMTP_USERNAME;
|
|
|
62 |
$mail->Password = SMTP_PASSWORD;
|
|
|
63 |
$mail->SMTPSecure = SMTP_SECURE;
|
|
|
64 |
$mail->Port = SMTP_PORT;
|
|
|
65 |
|
|
|
66 |
$mail->setFrom(SENDER_EMAIL, SENDER_NAME);
|
|
|
67 |
|
|
|
68 |
// Add a recipient
|
|
|
69 |
$mail->addAddress($to);
|
|
|
70 |
|
|
|
71 |
// Email subject
|
|
|
72 |
$mail->Subject = $subject;
|
|
|
73 |
|
|
|
74 |
// Set email format to HTML
|
|
|
75 |
$mail->isHTML(true);
|
|
|
76 |
|
|
|
77 |
// Email body content
|
|
|
78 |
$mail->Body = $mailContent;
|
|
|
79 |
$mail->AltBody = $mailContentText;
|
|
|
80 |
|
|
|
81 |
// Send email
|
|
|
82 |
if (!$mail->send()) {
|
|
|
83 |
error_log('Mailer error: ' . $mail->ErrorInfo);
|
|
|
84 |
}
|
|
|
85 |
}else{
|
|
|
86 |
//set content-type header for sending HTML email
|
|
|
87 |
$headers = "MIME-Version: 1.0" . "\r\n";
|
|
|
88 |
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
|
|
|
89 |
//additional headers
|
|
|
90 |
$headers .= 'From: '.SENDER_NAME.'<'.SENDER_EMAIL.'>' . "\r\n";
|
|
|
91 |
//send email
|
|
|
92 |
mail($to, $subject, $mailContent, $headers);
|
|
|
93 |
}
|
|
|
94 |
return true;
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
* Account verification email sender function
|
|
|
100 |
*/
|
|
|
101 |
if(! function_exists('emailVerification')){
|
|
|
102 |
function emailVerification($userData){
|
|
|
103 |
$emailVerifyLink = BASE_URL.'userAccount.php?verifyEmail=1&ac_code='.$userData['activation_code'];
|
|
|
104 |
$to = $userData['email'];
|
|
|
105 |
$subject = "Please Confirm Your Email | " . SITE_NAME;
|
|
|
106 |
$mailContent = '<html>
|
|
|
107 |
<head>
|
|
|
108 |
<title>Find Cheap Music Email Confirmation</title>
|
|
|
109 |
</head>
|
|
|
110 |
<body>
|
|
|
111 |
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-radius:6px;background-color:#ffffff;padding-top:15px;border-collapse:separate">
|
|
|
112 |
<tbody>
|
|
|
113 |
<tr>
|
|
|
114 |
<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">
|
|
|
115 |
<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>
|
|
|
116 |
<br>
|
|
|
117 |
Thank you for signing up with Find Cheap Music! Please confirm your email address by clicking the link below.
|
|
|
118 |
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:collapse">
|
|
|
119 |
<tbody>
|
|
|
120 |
<tr>
|
|
|
121 |
<td align="center" valign="middle" style="padding-top:25px;padding-right:15px;padding-bottom:25px;padding-left:15px">
|
|
|
122 |
<table border="0" cellpadding="0" cellspacing="0" style="border-radius:.25em;background-color:#4582e8;border-collapse:separate">
|
|
|
123 |
<tbody>
|
|
|
124 |
<tr>
|
|
|
125 |
<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">
|
|
|
126 |
<a href="'.$emailVerifyLink.'" style="font-weight:500;color:#ffffff;text-decoration:none">Confirm Email</a>
|
|
|
127 |
</td>
|
|
|
128 |
</tr>
|
|
|
129 |
</tbody>
|
|
|
130 |
</table>
|
|
|
131 |
</td>
|
|
|
132 |
</tr>
|
|
|
133 |
</tbody>
|
|
|
134 |
</table>
|
|
|
135 |
We look forward to serving you,<br><strong>'.SITE_NAME.' Team</strong>
|
|
|
136 |
</td>
|
|
|
137 |
</tr>
|
|
|
138 |
</tbody>
|
|
|
139 |
</table>
|
|
|
140 |
</body>
|
|
|
141 |
</html>';
|
|
|
142 |
|
|
|
143 |
$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";
|
|
|
144 |
$mailContentText .= "\r\nWe look forward to serving you,\r\n" . SITE_NAME . " Team";
|
|
|
145 |
|
| 35 |
- |
146 |
if(SMTP == true){
|
| 25 |
- |
147 |
$mail = PHPMailer_Init();
|
|
|
148 |
|
|
|
149 |
// SMTP configuration
|
|
|
150 |
$mail->isSMTP();
|
|
|
151 |
$mail->CharSet = "text/html; charset=UTF-8;";
|
|
|
152 |
$mail->WordWrap = 80;
|
|
|
153 |
$mail->Host = SMTP_HOST;
|
|
|
154 |
$mail->SMTPAuth = true;
|
|
|
155 |
$mail->Username = SMTP_USERNAME;
|
|
|
156 |
$mail->Password = SMTP_PASSWORD;
|
|
|
157 |
$mail->SMTPSecure = SMTP_SECURE;
|
|
|
158 |
$mail->Port = SMTP_PORT;
|
|
|
159 |
|
|
|
160 |
$mail->setFrom(SENDER_EMAIL, SENDER_NAME);
|
|
|
161 |
|
|
|
162 |
// Add a recipient
|
|
|
163 |
$mail->addAddress($to);
|
|
|
164 |
|
|
|
165 |
// Email subject
|
|
|
166 |
$mail->Subject = $subject;
|
|
|
167 |
|
|
|
168 |
// Set email format to HTML
|
|
|
169 |
$mail->isHTML(true);
|
|
|
170 |
|
|
|
171 |
// Email body content
|
|
|
172 |
$mail->Body = $mailContent;
|
|
|
173 |
$mail->AltBody = $mailContentText;
|
|
|
174 |
|
|
|
175 |
// Send email
|
|
|
176 |
if (!$mail->send()) {
|
|
|
177 |
error_log('Mailer error: ' . $mail->ErrorInfo);
|
|
|
178 |
}
|
|
|
179 |
} else {
|
|
|
180 |
//set content-type header for sending HTML email
|
|
|
181 |
$headers = "MIME-Version: 1.0" . "\r\n";
|
|
|
182 |
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
|
|
|
183 |
//additional headers
|
|
|
184 |
$headers .= 'From: '.SENDER_NAME.'<'.SENDER_EMAIL.'>' . "\r\n";
|
|
|
185 |
//send email
|
|
|
186 |
mail($to, $subject, $mailContent, $headers);
|
|
|
187 |
}
|
|
|
188 |
return true;
|
|
|
189 |
}
|
| 31 |
- |
190 |
}
|