47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
$token = $_POST['token'];
|
|
$message = $_POST['message'];
|
|
|
|
if ($token !== '1445') {
|
|
die("Error: invalid token.");
|
|
}
|
|
|
|
if (!$message) {
|
|
die("Error: invalid message (or lack thereof)");
|
|
}
|
|
|
|
$conn = mysql_connect(":/tmp/mysql.sock", "root", "");
|
|
if (!$conn) {
|
|
die("MySQL connection error: " . mysql_error());
|
|
}
|
|
mysql_select_db("mileslinden", $conn);
|
|
|
|
$result = mysql_query("SELECT * FROM subscribers");
|
|
$to_emails = array();
|
|
|
|
while ($row = mysql_fetch_assoc($result)) {
|
|
$to_emails[] = $row["email"];
|
|
}
|
|
|
|
$to = implode(", ", $to_emails);
|
|
$headers = array(
|
|
'From: no-reply@mileslinden.com',
|
|
'Reply-To: no-reply@mileslinden.com',
|
|
'X-Mailer: PHP/' . phpversion()
|
|
);
|
|
if (!mail($to, "MILES LINDEN CAMPAIGN ALERT", $message, implode("\r\n", $headers))) {
|
|
die("Error: failed to send email message.");
|
|
}
|
|
?>
|
|
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Miles Linden for San Jose City Council</title>
|
|
</head>
|
|
<body>
|
|
<h1>Great success!</h1>
|
|
</body>
|
|
</html>
|