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
/
1_reminder_mail.php
executable file
·79 lines (58 loc) · 2.29 KB
/
1_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
79
#!/usr/bin/php
<?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';
$day1 = "Thu, July 14, 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 LIMIT 0, 19";
$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($email);
}
$mail->isHTML(true);
$mail->Subject = '[Reminder/Webinar]: Virtual Event introducing OpenStack starts in 1 Day!';
$mail->Body = 'Hello'.' '.$row['firstname'].' '.$row['lastname'].','."<br/>"."<br/>"."This is a reminder that Virtual Event introducing OpenStack will begin in 1 Day on:"."<br/>"."<br/>"."<b><font color='blue'>$day1</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();
?>