-
Notifications
You must be signed in to change notification settings - Fork 2
/
mail.php
97 lines (72 loc) · 3.49 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
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
<?php
include('connection.php');
require 'PHPMailerAutoload.php';
$query1 = "SELECT * FROM patient where email = '" . $_POST["email"] . "'";
$result = mysqli_query($conn,$query1);
$count = mysqli_num_rows($result);
//echo "num row executed".$count."\n";
if($count==0)
{
$query = "INSERT INTO patient (first_name, last_name, email, gender,address,phone) VALUES('" . $_POST["first_name"] . "', '" . $_POST["last_name"] . "', '" . $_POST["email"] . "', '" . $_POST["gender"] . "', '" . $_POST["address"] . "', " . $_POST["mobile_no"] . ")";
$current_id = mysqli_query($conn,$query);
//echo $query."\n";
if(!empty($current_id))
{
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // 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 protected]'; // SMTP username
$mail->Password = 'kukku123'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'Mail test');
$add = $_POST["email"];
$mail->AddAddress($add); // Add a recipient
$mail->addReplyTo('[email protected]');
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Registration';
$mail->Body = '<div>This is the HTML message body <b>in bold!</b></div>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent';
}
}
}
else
{
$message = "User Email is already in use.";
echo $message;
}
?>
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // 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 protected]'; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'Mail test');
$mail->addAddress('[email protected]'); // Add a recipient
$mail->addReplyTo('[email protected]');
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = '<div>This is the HTML message body <b>in bold!</b></div>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}