• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/modules/newsletter/newsletter.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00015 #include_once("../../config.inc.php");
00016 #include_once("../../common.lib.php");
00017 
00018 $errorFile = fopen("send-errors.txt", 'w');
00019 $sentFile = fopen("send-success.txt", 'w');
00020 
00021 #connect();
00022 
00023 /*
00024  * Enter logic here to generate appropriate list of recipients
00025  * @return Array of strings, denoting the email ids of intended recipients
00026  */
00027 function getRecipientList() {
00028         //return array('jithinkr@gmail.com','mradul88@gmail.com');
00029         return file('mailinglisthexa');
00030 }
00031 
00032 function getMailContents() {
00033         return file_get_contents('pragyanmail_workshops_feb7');
00034 }
00035 
00036 function getMailSubject() {
00037         return 'Workshops and Guest Lectures @ Pragyan\'10 - NIT Trichy\'s Annual Techno-Management Fest'; // 'Pragyan 2010';
00038 }
00039 
00040 function registerMailSent($email) { global $sentFile; fwrite($sentFile, $email . "\n"); }
00041 function registerMailSendError($email) { global $errorFile; fwrite($errorFile, $email . "\n"); }
00042 
00043 $recipients = getRecipientList();
00044 $sender = 'Pragyan 10 <info@pragyan.org>';
00045 $replyTo = 'info@pragyan.org';
00046 $subject = getMailSubject();
00047 $message = getMailContents();
00048 
00049 for ($i = 0; $i < count($recipients); ++$i) {
00050         echo "Mailing {$recipients[$i]}... ";
00051         $headers =
00052                 "From: $sender\r\n" .
00053                 "Reply-To: $replyTo\r\n" .
00054                 "MIME-Version: 1.0\r\n" .
00055                 "Content-Type: multipart/alternative; boundary=\"000708050804010404000804\"";
00056 
00057         if (@mail($recipients[$i], $subject, $message, $headers)) {
00058                 echo "Success\n";
00059                 registerMailSent($recipients[$i]);
00060         }
00061         else {
00062                 echo "Failure\n";
00063                 registerMailSendError($recipients[$i]);
00064         }
00065 }
00066 
00067 ?>

Generated on Sun Jan 2 2011 04:55:32 for Pragyan CMS by  doxygen 1.7.1