-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmail.php
60 lines (47 loc) · 1.88 KB
/
mail.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
<?php
include 'db.php';
$pDatabase = Database::getInstance();
if (isset($_POST['sendMail']))
{
require 'PHPMailerAutoload.php';
require 'credential.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = EMAIL; // SMTP username
$mail->Password = PASS; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom(EMAIL, 'Yound minds ');
$mail->addAddress($_POST['sender_email']); // Add a recipient
// Name is optional
$mail->addReplyTo(EMAIL);
// Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST['subject'];
$mail->Body = '<div>This is the verification mail. Your OTP is <b>$otp</b> Enter this to activate your account on Young mind Bikes</div>';
$mail->AltBody = $_POST['message'];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Mailer</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST" action="">
<label>Your Email <input type="email" name="sender_email" /> </label>
<label>Subject <input type="text" name="subject" /> </label>
<label>Message <textarea name="message"></textarea> </label>
<input type="submit" name="sendMail" value="send" >
</form>
</body>
</html>