Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Html in mail su script PHP

    Ciao a tutti, scusate se il topic è doppio, triplo o OLD

    sto utilizzando un banalissimo script per l'invio di Newsletters, senza MYSQL, database o etc.

    perchè mi serve che le mail vengano scritte in un txt

    volevo però abilotare l'invio di mail in HTML sullo script

    in modo da usare footer e header con l'abilitazione HTML

    qual è il codice Php da implemetare per l'utilizzo di HTML via mail?

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    think simple think ringo

  3. #3
    grazie.
    ma non sono molto pratico e continuo ad avere un problema.

    io sto utilizzando questo script preso da Freephp.

    e mi piace il fatto che sia molto semplice, appena tre file Ph e un txt per la lista delle mail...

    volevo implementare l'HTML, qualcuno mi può aiutare?


    mailadmin.php

    <?
    if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
    {
    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Mailing List admin"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';
    exit;$emailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
    }
    else
    {
    $tu = strtolower($PHP_AUTH_USER);
    $pu = strtolower($PHP_AUTH_PW);
    include("config.php");
    if ($tu == strtolower($adminusername) && $pu == strtolower($adminpassword))
    {
    $fd = fopen ($listfile, "r");
    $contents = fread ($fd, filesize ($listfile));
    fclose ($fd);
    $entries = explode(",",$contents);
    for($i=0;$i<count($entries);$i++)
    {
    if ($entries[$i] != "")
    $choices .= "<OPTION VALUE=\"$entries[$i]\"> ".$entries[$i]."\n";
    }

    if ($cmd != "send")
    {
    $output = "
    <form action=\"?cmd=send\" method=\"post\">
    <table align=\"left\">
    <tr>
    <td>
    <SELECT MULTIPLE SIZE=5 NAME=sendto[]>
    <OPTION VALUE=\"All\" selected>Send to All
    $choices
    </select>
    </td>
    </tr>
    </table>
    <table align=\"center\">
    <tr>
    <td nowrap>Msg Subject</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
    </tr>
    <tr>
    <td nowrap valign=\"top\">Msg Body</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Include Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Include Footer</td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"submit\" value=\"Send Mail\"></td>
    </tr>
    <tr>
    <td></td>
    <td>Please keep in mind that it may take a while to send the messages depending how many people are on your list, let it finish sending</td>
    </tr>
    </table>
    ";
    }else
    {
    for ($i=0;$i<count($sendto);$i++)
    {
    echo "".$sendto[$i]." br>";
    }

    $footerd = fopen ($footerfile, "r");
    $thefooter = fread ($footerd, filesize ($footerfile));
    fclose ($footerd);

    $headerd = fopen ($headerfile, "r");
    $theheader = fread ($headerd, filesize ($headerfile));
    fclose ($headerd);

    if ($useheader == "yes")
    $message .= "".$theheader."\n\n";

    $message .= "".$body."\n\n";

    if ($usefooter == "yes")
    $message .= "".$thefooter."";

    if ($sendto[0] == "All")
    {
    for($i=0;$i<count($entries);$i++)
    {
    mail($entries[$i], $subject, $message,
    "From: ".$fromemail."");
    }
    }
    else
    {
    for($i=0;$icount($sendto);$i++)
    {
    mail($sendto[$i], $subject, $message,
    "From: ".$fromemail."");
    }
    }
    $output = "sent";
    }
    echo $output;


    }
    else // Does output if username/password is incorrect
    {
    echo " <html><body>Invalid Login/Password</body></html> ";
    }
    }


    maillist.php

    <?
    error_reporting(0);
    include("config.php");

    function checkmail ($email)
    {
    global $listfile;
    $fd = fopen ($listfile, "r");
    $contents = fread ($fd, filesize ($listfile));
    fclose ($fd);

    if (@stristr($contents,$email))
    $valid = "invalid";
    if (eregi("^[_\.0-9a-z-]+@([0-9a-z][-0-9a-z\.]+)\.([a-z]{2,3}$)", $email) && !isset($valid))
    $valid = "valid";
    else
    $valid = "invalid";

    return $valid;
    }

    if ($action == "subscribe" && isset($email))
    {
    $valid = checkmail($email);
    if ($valid == "valid")
    {
    $fp = fopen($listfile, 'a+');
    flock($fp,2);
    fwrite($fp,"".strtolower($email).",");
    fclose($fp);
    header ("Location: ".$welcome."");
    exit;

    }
    else {
    header ("Location: ".$error."");
    exit;
    }
    }
    elseif ($action == "unsubscribe" && isset($email))
    {
    $fd = fopen ($listfile, "r");
    $contents = fread ($fd, filesize ($listfile));
    fclose ($fd);
    $allpeople = "";
    $entries = explode(",",$contents);
    for($i=0;$i<count($entries);$i++)
    {
    if (strtolower($email) == strtolower($entries[$i]))
    $found = "yes";
    elseif ($entries[$i] != "")
    $allpeople .= "".$entries[$i].",";
    }
    if ($found == "yes")
    {
    $fp = fopen($listfile, 'w');
    fwrite($fp,$allpeople);
    fclose($fp);
    }
    header ("Location: ".$goodbye."");
    exit;

    }
    else
    header ("Location: ".$error."");
    exit;
    ?>
    nel file config.php ci sono solo i dati per la user, la pass dell'admin e i redirect ai vari file txt della lista utenti e dell'header e dell footer...

    qualcuno mi può aiutare?

  4. #4
    up

    che sono un uomo triste


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.