-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMail.php
More file actions
75 lines (71 loc) · 2.14 KB
/
testMail.php
File metadata and controls
75 lines (71 loc) · 2.14 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
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
<?php
include_once('include/db-config.php');
function addmailing($votesmotionid)
{
global $db_con;
$motionArray = array($votesmotionid);
$userSearch=$db_con->prepare("SELECT * from users where enabled=1;");
$userSearch->execute();
foreach ($motionArray as $motionid)
{
while ($row=$userSearch->fetch(PDO::FETCH_ASSOC))
{
$firstName = $row['first_name'];
$lastName = $row['last_name'] ;
$name="$firstName $lastName";
}
$motion=$db_con->prepare ("SELECT * from motions where motion_id = :motionid");
$motion->bindParam(':motionid',$motionid);
if (!$motion->execute())
{
var_dump($motion->errorinfo());
}
$body="<html>
<head>
<title>New Motion Addded</title>
</head>
<body>
<strong>This is a test</strong>";
$body .= "Dear $name <br /><br />";
$body .= "A new electronic vote has been created, please review it as soon as possible. The information
is below.";
while ($row=$motion->fetch(PDO::FETCH_ASSOC))
{
$motionid=$row['motion_id'];
$motionname=$row['motion_name'];
$dateadded=$row['dateadded'];
$motiondesc=$row['motion_description'];
$body .= "<br ><br />Motion ID: " . $motionid;
$body .= "<br />Motion Name: " . $motionname;
$body .= "<br />Date Added: " . $dateadded;
$body .= "<br />Motion Text: " . $motiondesc;
}//End of while
$body .= "</body>
</html>";
}//end of foreach
$boardEmail = "";
$emailSearch=$db_con->prepare("SELECT * FROM users where enabled=1");
$emailSearch->execute();
while ($row=$emailSearch->fetch(PDO::FETCH_ASSOC))
{
$boardEmail .= $row['email'] .",";
}
$boardEmail="michaelbrown.tsbod@gmail.com";
$subject = "New Motion " . $motionid;
$message = $body;
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "To: $boardEmail\r\n";
$headers .= "From: Tanyard Springs Votes <noreply@tanyardspringshoa.com>\r\n";
//mailing
if (mail($boardEmail,$subject,$message,$headers))
{
print "Email successfully sent";
}
else
{
print "An error occured";
}
}//end of function
addmailing(52);