-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_function.php
31 lines (29 loc) · 909 Bytes
/
mail_function.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
<?php
function sendOTP($email,$otp) {
include('vendor/autoload.php');
include('vendor/PHPMailer.php');
include('vendor/SMTP.php');
include('vendor/OAuth.php');
include('vendor/Exception.php');
include('vendor/get_oauth_token.php');
include('vendor/POP3.php');
$message_body = "One Time Password for PHP login authentication is:<br/><br/>" . $otp;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl'; // tls or ssl
$mail->Port = "587";
$mail->Username = "[email protected]";
$mail->Password = "Whiplash10";
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->SetFrom('[email protected]', 'Rahul Bhandari');
$mail->AddAddress($email);
$mail->Subject = "OTP to Login";
$mail->MsgHTML($message_body);
$mail->IsHTML(true);
$result = $mail->Send();
return $result;
}
?>