forked from DarshanMaradiya/OnlineMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
175 lines (144 loc) · 7.18 KB
/
functions.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use Encryption\Encryption;
function verifyMail($id, $mailAddress, $name = "")
{
require('PHPMailer/Exception.php');
require('PHPMailer/PHPMailer.php');
require('PHPMailer/SMTP.php');
require('SupportClasses/Encryption.php');
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'foreverlearners1234@gmail.com'; // SMTP username
$mail->Password = 'dontaskdonttell'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('foreverlearners1234@gmail.com', 'OnlineMusic');
$mail->addAddress($mailAddress, "simple"); // Add a recipient
// $mail->addCC();
// $mail->addBCC();
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$encrypted_id = Encryption::encrypt_id($id);
$msg = "Click <a href=\"localhost/onlinemusic/mailverification.php?id=".$encrypted_id."\" style=\"color:red;\">here</a> for verification!";
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Verify Your OnlineMusic Account';
$mail->Body = $msg;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
// echo 'Message has been sent';
return true;
} catch (Exception $e) {
// echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}
function resetPasswordMail($id, $mailAddress, $name = "", $otp)
{
require('PHPMailer/Exception.php');
require('PHPMailer/PHPMailer.php');
require('PHPMailer/SMTP.php');
require('SupportClasses/Encryption.php');
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'foreverlearners1234@gmail.com'; // SMTP username
$mail->Password = 'dontaskdonttell'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('foreverlearners1234@gmail.com', 'OnlineMusic');
$mail->addAddress($mailAddress, "simple"); // Add a recipient
// $mail->addCC();
// $mail->addBCC();
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$encrypted_id = Encryption::encrypt_id($id);
$msg = $otp."<br>Enter this number";
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Reset Password of Your OnlineMusic Account';
$mail->Body = $msg;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
// echo 'Message has been sent';
return true;
} catch (Exception $e) {
// echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}
function changePass($id, $email)
{
require('PHPMailer/Exception.php');
require('PHPMailer/PHPMailer.php');
require('PHPMailer/SMTP.php');
require('SupportClasses/Encryption.php');
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'foreverlearners1234@gmail.com'; // SMTP username
$mail->Password = 'dontaskdonttell'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('foreverlearners1234@gmail.com', 'OnlineMusic');
$mail->addAddress($email, "simple"); // Add a recipient
// $mail->addCC();
// $mail->addBCC();
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$encrypted_id = Encryption::encrypt_id($id);
date_default_timezone_set("Asia/Kolkata");
$date = substr(date("d.m.Y"), 0, 2).substr(date("d.m.Y"), 3, 2).substr(date("d.m.Y"), 6, 4);
$time = $date.substr(date("H:i:sa"), 0, 2).substr(date("H:i:sa"), 3, 2).substr(date("H:i:sa"), 6, 2);
$encrypted_id = $time.$encrypted_id;
$msg = "Click <a href=\"localhost/OnlineMusic/resetpass.php?id=".$encrypted_id."\" style=\"color:red;\">here</a> to change password!<br>*Link valid for 10 minutes";
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Change Password of Your OnlineMusic Account';
$mail->Body = $msg;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
// echo 'Message has been sent';
return true;
} catch (Exception $e) {
// echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}
?>