This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_reminder_mail.php
executable file
·78 lines (57 loc) · 2.28 KB
/
2_reminder_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
<?php
/***** EDIT BELOW LINES *****/
$DB_Server = "localhost"; // MySQL Server
$DB_Username = "root"; // MySQL Username
$DB_Password = "pass"; // MySQL Password
$DB_DBName = "webinar"; // MySQL Database Name
$DB_TBLName = "users_list"; // MySQL Table Name
require '/lib/PHPMailer/class.phpmailer.php';
require '/lib/PHPMailer/PHPMailerAutoload.php';
$day2 = "FRI, July 15, 2016 3:00 - 4:00PM IST / 5:30 - 6:30PM SGT / 7:30 - 8:30PM AEST";
/***** DO NOT EDIT BELOW LINES *****/
// Create MySQL connection
// Create connection
$conn = new mysqli($DB_Server, $DB_Username, $DB_Password, $DB_DBName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Execute query
$sql = "SELECT * FROM $DB_TBLName";
$result = $conn->query($sql) or die("Failed to execute query:<br />" . mysql_error(). "<br />" . mysql_errno());
if ($result->num_rows > 0) {
// Looping for each row
while($row = $result->fetch_assoc()) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'xxxxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
$mail->From = '[email protected]';
$mail->FromName = 'OneCloud Consulting';
$mail->clearAddresses();
foreach($row as $email)
{
$mail->addAddress($row["email"]);
}
$mail->isHTML(true);
$mail->Subject = '[Reminder/Webinar]: Virtual Event introducing OpenStack starts in 1 Day!';
$mail->Body = 'Hello'.' '.<b>$row['firstname'].' '.$row['lastname']</b>.','."<br/>"."<br/>"."This is a reminder that Virtual Event introducing OpenStack will begin in 1 Day on:"."<br/>"."<br/>"."<b><font color='blue'>$day2</font></b>"."<br/>"."<br/>"."<img src=\"cid:logoimg\"/>"."<br/>"."<br/>"."<br/>"."<br/>"."<br/>".'Regards,'."<br/>".'<b>OneCloud Consulting Team</b>';
$mail->AddEmbeddedImage("images/reminder.png", 'logoimg');
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo 'Message has been sent';
}
}
}
else {
echo "0 results";
}
$conn->close();
?>