help me please O_o

  • Creatore Discussione Creatore Discussione kimiko
  • Data di inizio Data di inizio

kimiko

Nuovo Utente
23 Set 2008
2
0
0
ciao ragazzi qualkuno mi potrebbe dare una mano con questo script php di invio news/mail...
quello che vorrei e che potesse mandare messaggi in formato html ... cosa che mi sta facendo diventare pazzo:incazz2: ma nulla O_o
anke se credo che aruba blocchi l invio di mail html dai suoi server pero quello sara un problema che risolvero in un altro modo 0:)


PHP:
<?
// Some variables;
// Your emails list file;
$filelist = "emails.txt";
// Email headers that subscribed users see
// when you send them an email;
$adminmail = "info@miamail.com";
$emailheaders = "From: " . $adminmail . "\nReply-To: " . $adminmail;
// By default we display entries;
if (!isset($mode))
   $mode = "unknown";
   
// Since all administration is in one file,
// we choose what to to do now;
switch ($mode) {
       case "create": createList(); break;
       case "display": displayEntries($filelist); break;
       case "add": addEntry($email); break;
       case "edit": displayEditForm($id); break;
       case "doEdit": editEntry($email, $oldvalue); break;
       case "delete": deleteEntry($id); break;
       case "send": sendNews($subject, $message); break;
       default:
       if (file_exists($filelist)) {
          displayEntries(); displayAddEntryForm();
       }

}



/* THIS IS THE PART WHERE WE CREATE A MAILING LIST FILE AUTOMATICALLY */
/* IGNORE IT IF YOU HAVE CREATED IT MANUALLY (NOTHING WILL BE DISPLAYED */
if (!file_exists($filelist)) {
   echo "<h2>Please, make sure you have 777 permissions for current
   directory to create the mailing list file and click the button or
    create it manually and set 666 permissions on it</h2>";

   echo "<form name=createFile action=admin_mailing.php method=post>";
   echo "<input type=submit name=mode value=create mailing list file>";
   echo "</form>";
   exit;
}

function createList() {
         $fp = fopen($GLOBALS["filelist"], "w");
         if ($fp) {
            echo "<h2>Mailing list file created successfully!</h2>";
            echo "<b>" . $GLOBALS["filelist"] . "</b>";
            echo "<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>";
            exit;
         }
         else
            echo "Error!";
}
/**************************************************************************/


// Sends news to subscribers;
function sendNews($subject, $message) {
         $filecontents = file($GLOBALS["filelist"]);
         for ($i=0;$i<sizeof($filecontents);$i++) {
             $a = mail($filecontents[$i], $subject, stripslashes($message), $GLOBALS["emailheaders"]);
             if (!$a)
                exit;
         }
         echo "Spam sent! ;)";
         echo "<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>";
         exit;
}

// Displays the form to add emails to list;
function displayAddEntryForm() {
         echo "<h1>Add email to list:</h1>";
         echo "<form name=addEntry action=admin_mailing.php method=get>";
         echo "<input type=text name=email>";
         echo "<input type=hidden name=mode value=add>";
         echo "<input type=submit name=submit value=add>";
         echo "</form>";
}

// Adds emails to list;
function addEntry($email) {
         $fp = fopen($GLOBALS["filelist"], "a");
         $emailsize = strlen($email . "\n");
         $fw = fwrite($fp, $email . "\n", $emailsize);
         if ($fw) {
            echo "<h2><div align=center>Entry added successfully!</div></h2>";
            echo "<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>";
            exit;
         }
         else
            echo "Error!";
}

// Displays emails from list;
// by default it display last 10 emails;
function displayEntries() {
         echo "Show last <a href=admin_mailing.php?limit=10>10 emails</a> ||
         <a href=admin_mailing.php?limit=20>20 emails</a> ||
         <a href=admin_mailing.php?limit=50>50 emails</a> ||
         <a href=admin_mailing.php?showall=>Show all</a><p>";
         $filecontents = file($GLOBALS["filelist"]);
         if (isset($GLOBALS["limit"]))
            $limit = $GLOBALS["limit"];
         if ((!isset($GLOBALS["limit"])) and (!isset($GLOBALS["showall"])))
            $limit=10;
         if (isset($GLOBALS["showall"])) {
            for ($i=sizeof($filecontents)-1;$i>=0;$i--) {
                echo $filecontents[$i] . " <a href=admin_mailing.php?mode=edit&id=" .
                $filecontents[$i] . ">Edit</a> || <a href=admin_mailing.php?mode=delete&id=" .
                $filecontents[$i] . ">Delete</a><br>";
            }
         }
        elseif (isset($limit)) {
                $count = 1;
                for ($i=sizeof($filecontents)-1;$count<=$limit;$i--) {
                echo $filecontents[$i] . " <a href=admin_mailing.php?mode=edit&id=" .
                $filecontents[$i] . ">Edit</a> || <a href=admin_mailing.php?mode=delete&id=" .
                $filecontents[$i] . ">Delete</a><br>";
                $count++;
            }
        }


}

// Displays the form to edit an email;
function displayEditForm($id) {
         echo "<h1>Edit email:</h1>";
         echo "<form name=editForm action=admin_mailing.php method=get>";
         echo "<input type=text name=email value=" . $id . ">";
         echo "<input type=hidden name=oldvalue value=" . $id . ">";
         echo "<input type=hidden name=mode value=doEdit>";
         echo "<input type=submit name=submit value=update>";
         echo "</form>";
         exit;
}

// Edits an email and writes the updated file;
function editEntry($email, $oldvalue) {
         $filecontents = file($GLOBALS["filelist"]);
         for ($i=0;$i<sizeof($filecontents);$i++) {
             if (chop($filecontents[$i]) == $oldvalue) {
                $filecontents[$i] = $email . "\n";
                $fp = fopen($GLOBALS["filelist"], "w+");
                for ($a=0;$a<sizeof($filecontents);$a++) {
                    $emailsize = strlen($filecontents[$a] . "\n");
                    $fw = fwrite($fp, $filecontents[$a], $emailsize);
                }
                echo "<h2><div align=center>Entry changed!</div></h2>";
                echo "<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>";
                exit;
             }
         }
}

// Deletes an email and writes an updated file;
function deleteEntry($id) {
         $filecontents = file($GLOBALS["filelist"]);
         for ($i=0;$i<sizeof($filecontents);$i++) {
             if (chop($filecontents[$i]) == $id) {
                $filecontents[$i] = "";
                $fp = fopen($GLOBALS["filelist"], "w+");
                for ($a=0;$a<sizeof($filecontents);$a++) {
                    $emailsize = strlen($filecontents[$a]);
                    $fw = fwrite($fp, $filecontents[$a], $emailsize);
                }
                echo "<h2><div align=center>Entry deleted!</div></h2>";
                echo "<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>";
                exit;
                
             }
         }
}

?>
<h2>Enter any text here that you want to send to all your subscribers:</h2>
<form name=sendEmail action=admin_mailing.php method=post>
Subject:<br><input type=text name=subject><br>
Message body:<br><textarea name=message rows=10 cols=50></textarea><br>
<input type=submit name=mode value=send>
</form>

kimik0
 
Parlando del test locale, il problema sta nel fatto che le mail non partono o che non arrivano in HTML?
 

Discussioni simili