-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail_function.php
More file actions
43 lines (32 loc) · 1.28 KB
/
Copy pathmail_function.php
File metadata and controls
43 lines (32 loc) · 1.28 KB
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
<?php
function sendOTP($email,$otp) {
require('phpmailer.php');
require('smtp.php');
require('Exception.php');
// require('phpmailer/class.smtp.php');
// require_once("./phpmailer.php");
$message_body = "One Time Password for PHP login authentication is:<br/><br/>" . $otp;
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->Port = '587';
// $mail->Port ='25';
$mail->isSMTP(); // Set mailer to use SMTP // Specify main and backup SMTP servers
// Set mailer to use SMTP
// $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->Host = gethostbyname('smtp.gmail.com');
// $mail->SMTPAuth = false;
// $mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true; // Authentication must be disabled
$mail->Username = 'hariharan0907@gmail.com';
$mail->Password = 'liveandletlive';
$mail->SMTPSecure= 'tls';
$mail->Mailer = 'smtp';
$mail->SetFrom('hariharan0907@gmail.com','hari');
$mail->AddAddress($email);
$mail->Subject = 'OTP to Login';
$mail->MsgHTML($message_body);
$mail->IsHTML(true);
$result = $mail->Send();
return $result;
}
?>