Subversion Repositories cheapmusic

Rev

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