-
Notifications
You must be signed in to change notification settings - Fork 1
/
mail.php
executable file
·35 lines (32 loc) · 1.08 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
<?php
include "connection.php";
session_start();
$rollno = $_SESSION['roll_no'];
$fetch=mysqli_query($connection,"select * from std_detail where std_rollno='$rollno' ");
while($res=mysqli_fetch_assoc($fetch)){
$email=$res['std_email'];
}
//PHPMailer\PHPMailer\
require 'src/PHPMailer.php';
require 'src/SMTP.php';
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
$mail->IsSMTP(); // enable SMTP
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465; // or 587
// $mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "8777385365";
$mail->SetFrom("[email protected]");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress($email);
$mail->addAttachment($rollno.'.pdf' );
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
header("Location: Admin.php");
}
?>