summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authordeva <deva>2010-02-25 20:30:01 +0000
committerdeva <deva>2010-02-25 20:30:01 +0000
commita741351d5c91913f22255b8e9e5d4586c70735d6 (patch)
tree536338130df920e5851462b04fa13d42b6fc889f /utils
parente84a854e54adf07d0bda64f8e3a4182940b44a97 (diff)
Split up some of the mailcode in order to be able to reuse it in the upcoming pressrelease module.
Diffstat (limited to 'utils')
-rw-r--r--utils/mail.php25
-rw-r--r--utils/modules/newsletter.php57
2 files changed, 48 insertions, 34 deletions
diff --git a/utils/mail.php b/utils/mail.php
new file mode 100644
index 0000000..866bad4
--- /dev/null
+++ b/utils/mail.php
@@ -0,0 +1,25 @@
+<?php /* -*- mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+class Email {
+ public $timestamp;
+ public $email;
+
+ public function Email($email, $timestamp)
+ {
+ $this->email = $email;
+ $this->timestamp = $timestamp;
+ }
+
+ public function send($subject, $message,
+ $sender, $replyto)
+ {
+ $headers = "From: " . $sender . "\r\n";
+ $headers .= "Reply-To: " . $replyto . "\r\n";
+ $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
+ $headers .= "X-Mailer: PHP/" . phpversion();
+
+ return mail($this->email, $subject, $message, $headers);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/utils/modules/newsletter.php b/utils/modules/newsletter.php
index 5a0cade..ef172e0 100644
--- a/utils/modules/newsletter.php
+++ b/utils/modules/newsletter.php
@@ -1,30 +1,8 @@
<?php /* -*- mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-class Email {
- public $timestamp;
- public $email;
+global $UTIL_DIR;
- public function Email($email, $timestamp)
- {
- $this->email = $email;
- $this->timestamp = $timestamp;
- }
-
- public function send($subject, $message,
- $subject_prefix, $sender, $replyto, $footer, $unsubscribe_url)
- {
- $message .= "\n\n".$footer;
- $message .= "\n\nTo stop receiving this newsletter, click the following link: ".$unsubscribe_url."&action=unsubscribe&email=". $this->email . "\n";
- $headers = "From: " . $sender . "\r\n";
- $headers .= "Reply-To: " . $replyto . "\r\n";
- $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
- $headers .= "X-Mailer: PHP/" . phpversion();
- $subject = "[".$subject_prefix."] " . $subject;
-
- $ret = mail($this->email, $subject, $message, $headers);
- if(!$ret) echo "Fail(".$this->email.")";
- }
-}
+include_once($UTIL_DIR . "/mail.php");
class Mailinglist {
private $file;
@@ -125,8 +103,26 @@ class Mailinglist {
return $str;
}
+ public function postSingle($email, $subject, $message)
+ {
+ $subject = "[".$this->subj_prefix."] " . $subject;
+
+ $message .= "\n\n".$this->footer;
+ $message .= "\n\nTo stop receiving this newsletter, click the following link: ".
+ $this->unsubscribe_url."&action=unsubscribe&email=". $email->email . "\n";
+
+ $email->send($subject, $message, $this->sender, $this->replyto);
+ }
+
public function post($subject, $message)
{
+ $subject = "[".$this->subject_prefix."] " . $subject;
+
+ $message .= "\n\n".$this->footer;
+ $message .= "\n\nTo stop receiving this newsletter, click the following link: ".
+ $this->unsubscribe_url."&action=unsubscribe&email=". $this->email . "\n";
+
+
$sz = sizeof($this->mailinglist);
echo "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\n&lt;";
@@ -138,10 +134,8 @@ class Mailinglist {
$steps = floor($sz / 10) + 1;
foreach($this->mailinglist as $email) {
- $email->send($subject, $message,
- $this->subj_prefix, $this->sender,
- $this->replyto, $this->footer,
- $this->unsubscribe_url);
+
+ $this->postSingle($email, $ubject, $message);
$pct = $num / $sz * 100;
if($pct >= $lvl) {
@@ -190,12 +184,7 @@ class Newsletter {
case "preview":
$testmail = new Email($vars["testaddr"], 0);
echo "<div class=\"preview\">\n";
- echo $testmail->send($vars["subject"], $vars["content"],
- $this->mailinglist->subj_prefix,
- $this->mailinglist->sender,
- $this->mailinglist->replyto,
- $this->mailinglist->footer,
- $this->mailinglist->unsubscribe_url);
+ $this->mailinglist->postSingle($testmail, $vars["subject"], $vars["content"]);
echo "A test mail has been sent to ".$vars["testaddr"]."</div>\n";
echo "<p>Looking ok?</p>";
$form = new Form("send");