Visualizzazione risultati 1 fino 15 di 15

Discussione: Adattare Newsletter (NO AV) al tempo di spedizioni mail

  1. #1
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Wink Adattare Newsletter (NO AV) al tempo di spedizioni mail

    Come si dicono in molti post prima di questo AlterVista ha un tempo limite per l'invio della mail, cioè AlterVista permette di inviare 3 mail ogni 2 secondi. Dopo aver letto questo post ho capito che potrei usare la funzione usleep() o sleep() ma non ho capito bene come devo inserirle nel codice della mia newsletter. Qualcuno mi può aiutare?
    Codice PHP:
    <?
    if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
    {
    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Pagina Amministratore Newsletter"');
    header('HTTP/1.0 401 Unauthorized');
    echo
    'Authorization Required.';
    exit;
    }
    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>Invia a tutti
    $choices
    </select>
    </td>
    </tr>
    </table>
    <table align=\"center\">
    <tr>
    <td nowrap>Oggetto</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
    </tr>
    <tr>
    <td nowrap valign=\"top\">Messaggio</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Includi Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Includi Footer</td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"submit\" value=\"Invia Messaggio\"></td>
    </tr>
    <tr>
    <td></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;$i<count($sendto);$i++)
    {
    mail($sendto[$i], $subject, $message,
    "From: ".$fromemail."");
    }
    }
    $output = "sent";
    }
    echo
    $output;


    }
    else
    // Does output if username/password is incorrect
    {
    echo
    " <html><body><center>Login Errato!</center></body></html> ";
    }
    }
    ?>
    Apprezzi l'aiuto? Offrimi un caffè!

  2. #2
    Ospite Guest

    Predefinito

    Citazione Originalmente inviato da miki92
    ma non ho capito bene come devo inserirle nel codice
    Subito dopo le varie esecuzioni della funzione mail().

  3. #3
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Quindi? Prendendo un parte di righe:
    Codice PHP:
    mail($sendto[$i], $subject, $message, "From: ".$fromemail."");
    sleep();
    Apprezzi l'aiuto? Offrimi un caffè!

  4. #4
    Ospite Guest

    Predefinito

    In sleep() va passato come argomento il numero di secondi di pausa.
    Come consigliato da jostock però usa usleep():
    Codice PHP:
    usleep(667000);

  5. #5
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Codice PHP:
    <?
    if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
    {
    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Pagina Amministratore Newsletter"');
    header('HTTP/1.0 401 Unauthorized');
    echo
    'Authorization Required.';
    exit;
    }
    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>Invia a tutti
    $choices
    </select>
    </td>
    </tr>
    </table>
    <table align=\"center\">
    <tr>
    <td nowrap>Oggetto</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
    </tr>
    <tr>
    <td nowrap valign=\"top\">Messaggio</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Includi Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Includi Footer</td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"submit\" value=\"Invia Messaggio\"></td>
    </tr>
    <tr>
    <td></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;$i<count($sendto);$i++)
    {
    mail($sendto[$i], $subject, $message,
    "From: ".$fromemail."");
    usleep(667000);
    }
    }
    $output = "sent";
    }
    echo
    $output;


    }
    else
    // Does output if username/password is incorrect
    {
    echo
    " <html><body><center>Login Errato!</center></body></html> ";
    }
    }
    ?>
    Cosi?
    Apprezzi l'aiuto? Offrimi un caffè!

  6. #6
    Ospite Guest

    Predefinito

    Si, solo che devi mettere quel codice anche dopo:
    Codice PHP:
    mail($entries[$i], $subject, $message, "From: ".$fromemail."");
    Spero funzioni, visto il "problema" del tempo massimo di esecuzione script

  7. #7
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Infatti non funziona. Le mail giungono sempre allo stesso indirizzo e il messaggio che mi annuncia che l'esito è ok non appare. Come devo fare? Anche con il codice di prima molti non ricevevano le mie mail. Ditemi voi cosa devo fare?
    Apprezzi l'aiuto? Offrimi un caffè!

  8. #8
    Ospite Guest

    Predefinito

    Una soluzione è l'uso del BCC/CCN o del CC nell'intestazione.
    Leggi questo mio post.
    Nel tuo caso:
    Codice PHP:
    $a=array();
    for(
    $i=0;$i<count($sendto);$i++)
    {
    array_push($a,$sendto[$i]);
    }
    $bcc="";
    $a=array_shift($a);
    foreach(
    $a as $email){
    $bcc .= $email.",";
    }
    mail($sendto['0'], $subject, $message,
    "From: ".$fromemail."\r\n"."bcc: ".$bcc);
    Usa lo stesso script per la seconda esecuzione di mail().

  9. #9
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Sisi quel post l'avevo già letto. Ma dove devo inserire questo tuo codice?
    Apprezzi l'aiuto? Offrimi un caffè!

  10. #10
    Ospite Guest

    Predefinito

    Ti posto tutto lo script per intero, cosi non hai più bisogno di fare domande.
    Codice PHP:
    <?
    if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
    {
    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Pagina Amministratore Newsletter"');
    header('HTTP/1.0 401 Unauthorized');
    echo
    'Authorization Required.';
    exit;
    }
    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>Invia a tutti
    $choices
    </select>
    </td>
    </tr>
    </table>
    <table align=\"center\">
    <tr>
    <td nowrap>Oggetto</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
    </tr>
    <tr>
    <td nowrap valign=\"top\">Messaggio</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Includi Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Includi Footer</td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"submit\" value=\"Invia Messaggio\"></td>
    </tr>
    <tr>
    <td></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")
    {
    $a=array();
    for(
    $i=0;$i<count($entries);$i++)
    {
    array_push($a,$entries[$i]);
    }
    $bcc="";
    $a=array_shift($a);
    foreach(
    $a as $email){
    $bcc .= $email.",";
    }
    mail($entries['0'], $subject, $message,
    "From: ".$fromemail."\r\n"."bcc: ".$bcc);
    }
    else
    {
    $a=array();
    for(
    $i=0;$i<count($sendto);$i++)
    {
    array_push($a,$sendto[$i]);
    }
    $bcc="";
    $a=array_shift($a);
    foreach(
    $a as $email){
    $bcc .= $email.",";
    }
    mail($sendto['0'], $subject, $message,
    "From: ".$fromemail."\r\n"."bcc: ".$bcc);
    }
    $output = "sent";
    }
    echo
    $output;


    }
    else
    // Does output if username/password is incorrect
    {
    echo
    " <html><body><center>Login Errato!</center></body></html> ";
    }
    }
    ?>

  11. #11
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Sembra non funzionare.
    Apprezzi l'aiuto? Offrimi un caffè!

  12. #12
    Guest

    Predefinito

    Codice PHP:
    <?
    if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
    {
    // If empty, send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Pagina Amministratore Newsletter"');
    header('HTTP/1.0 401 Unauthorized');
    echo
    'Authorization Required.';
    exit;
    }
    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 ( !isset(
    $_POST['submit']) )
    {
    $output = "
    <form action=\""
    . $_SERVER['PHP_SELF'] . "\" method=\"post\">
    <table align=\"left\">
    <tr>
    <td>
    <SELECT MULTIPLE SIZE=\"5\" NAME=\"sendto[]\">
    <OPTION VALUE=\"All\" selected>Invia a tutti
    $choices
    </select>
    </td>
    </tr>
    </table>
    <table align=\"center\">
    <tr>
    <td nowrap>Oggetto</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
    </tr>
    <tr>
    <td nowrap valign=\"top\">Messaggio</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Includi Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Includi Footer</td>
    </tr>
    <tr>
    <td></td>
    <td><input type=\"submit\" value=\"Invia Messaggio\" name=\"submit\"></td>
    </tr>
    <tr>
    <td></td>
    </tr>
    </table>
    "
    ;
    }else
    {
    $sendto = $_POST['sendto'];

    $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 .= $_POST['body']."\n\n";

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

    if (
    $sendto[0] == "All")
    {
    $a = $sendto;
    $a = array_shif($a);
    $bcc="";
    foreach(
    $a as $k => $email){
    if(
    $k != 0)
    {
    $bcc .= $email.",";
    }
    }
    mail($a[0], $subject, $message, "From: ".$fromemail."\r\n"."bcc: ".$bcc);
    }
    else
    {
    $a=$sendto;
    $a=array_shift($a);
    $bcc="";
    foreach(
    $a as $k => $email){
    if(
    $k != 0)
    {
    $bcc .= $email.",";
    }
    }
    mail($a['0'], $subject, $message, "From: ".$fromemail."\r\n"."bcc: ".$bcc);
    }
    $output = "sent";
    }

    for (
    $i=0;$i<count($a);$i++)
    {
    echo
    "".$a[$i]." <br>";
    }
    echo
    $output;


    }
    else
    // Does output if username/password is incorrect
    {
    echo
    " <html><body><center>Login Errato!</center></body></html> ";
    }
    }
    ?>
    ho migliorato un po il codice, vedi se funziona!

  13. #13
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Errore:
    
    Fatal error: Call to undefined function: array_shif() in /membri/miki92/newsletter/admin.php on line 84
    Apprezzi l'aiuto? Offrimi un caffè!

  14. #14
    Ospite Guest

    Predefinito

    Al posto di:
    $a = array_shif($a);
    metti:
    $a = array_shift($a);
    Piccolo errore di battitura di Jostock

  15. #15
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    A differenza di prima ora mi viene segnalato l'invio corretto della newsletter ma non mi giunge alcuna mail.
    Apprezzi l'aiuto? Offrimi un caffè!

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •