Subversion Repositories cheapmusic

Rev

Rev 35 | Rev 73 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
65 - 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
    }
25 - 20
}
21
 
22
/*
23
 * Reset new password email sender function
65 - 24
*/
25
if (!function_exists('forgotPassEmail')) {
26
    function forgotPassEmail($userData) {
27
        $resetPassLink = BASE_URL . 'resetPassword.php?fp_code=' . $userData['forgot_pass_identity'];
25 - 28
        $to = $userData['email'];
65 - 29
        $subject = "Password Update Request | " . SITE_NAME;
25 - 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">
65 - 39
				<a href="' . $resetPassLink . '" style="font-weight:500;color:#ffffff;text-decoration:none">Reset Password</a>
25 - 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>
65 - 45
        <p>Regards,<br/><strong>' . SITE_NAME . ' Team</strong></p></body></html>';
25 - 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";
65 - 52
 
53
        if (SMTP == true) {
54
            $mail = PHPMailer_Init();
55
 
56
            // SMTP configuration
57
            $mail->isSMTP();
58
            $mail->Host = SMTP_HOST;
59
            $mail->SMTPAuth = true;
60
            $mail->Username = SMTP_USERNAME;
61
            $mail->Password = SMTP_PASSWORD;
62
            $mail->SMTPSecure = SMTP_SECURE;
63
            $mail->Port = SMTP_PORT;
64
 
65
            $mail->setFrom(SENDER_EMAIL, SENDER_NAME);
66
 
67
            // Add a recipient
68
            $mail->addAddress($to);
69
 
70
            // Email subject
71
            $mail->Subject = $subject;
72
 
73
            // Set email format to HTML
74
            $mail->isHTML(true);
75
 
76
            // Email body content
77
            $mail->Body = $mailContent;
78
            $mail->AltBody = $mailContentText;
79
 
80
            // Send email
81
            if (!$mail->send()) {
82
                error_log('Mailer error: ' . $mail->ErrorInfo);
83
            }
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
        }
25 - 94
        return true;
95
    }
96
}
97
 
98
/*
99
 * Account verification email sender function
65 - 100
*/
101
if (!function_exists('emailVerification')) {
102
    function emailVerification($userData) {
103
        $emailVerifyLink = BASE_URL . 'userAccount.php?verifyEmail=1&ac_code=' . $userData['activation_code'];
25 - 104
        $to = $userData['email'];
65 - 105
        $subject = "Please Confirm Your Email | " . SITE_NAME;
25 - 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">
65 - 126
											<a href="' . $emailVerifyLink . '" style="font-weight:500;color:#ffffff;text-decoration:none">Confirm Email</a>
25 - 127
										</td>
128
									</tr>
129
								</tbody>
130
								</table>
131
							</td>
132
						</tr>
133
					</tbody>
134
					</table>
65 - 135
					We look forward to serving you,<br><strong>' . SITE_NAME . ' Team</strong>
25 - 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
 
65 - 146
        if (SMTP == true) {
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
        }
180
        else {
181
            //set content-type header for sending HTML email
182
            $headers = "MIME-Version: 1.0" . "\r\n";
183
            $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
184
            //additional headers
185
            $headers .= 'From: ' . SENDER_NAME . '<' . SENDER_EMAIL . '>' . "\r\n";
186
            //send email
187
            mail($to, $subject, $mailContent, $headers);
188
        }
25 - 189
        return true;
190
    }
31 - 191
}