Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Question Unanswered: Sending Bulk Email from a PHP/mySQL based website

    i have designed a site that allows a user to input their email address to subscribe to a mailing list. but i am having several problems creating the page that sends emails to all the users that are in my newsletter table. the page has a text box to allow subject change and another text box to allow the bodytext to be inputted.

    any help would be greatly recieved.

    thanks

  2. #2
    Join Date
    May 2004
    Posts
    7

    Lightbulb Send Masive email

    I use the following code to send email to users register on one of my tables,
    and put a flag in the "on" state to check what users I have send the email.

    <?php

    function actualiza($email)
    {
    $result2 = mysql_query('UPDATE SentEmails SET Status ="on" WHERE Correo="'.$em
    ail.'"');
    mysql_query("COMMIT");


    }

    function enviar($email, $contacto)
    {
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: Your_Name<response_email@domain.mx>\r\n";
    $headers .= "Reply-To:valid_email@validdomain.com\r\n";
    $subject="As is";
    $ft = "Hello ";
    $ft = $ft.$texto; // the var texto is passed as a http_var in ?texto= by the form of the html file
    $mailresult=mail($email, $subject, $ft, $headers);
    if($mailresult==true)
    {
    echo "<h1>Mail Sent!</h1>";
    }
    else
    {
    echo "<h1>Email Failure</h1>";
    }
    }


    $module_name = basename (dirname(_FILE_));
    $index = 1;
    global $module_name;
    $conex = mysql_connect("localhost", "root", "")
    or die("Error en la conexion no encuentro el servidor de datos");

    mysql_select_db("databasename",$conex);
    $consulta = 'select Correo, NombreContacto from MailsSent where Status<>"On"';
    $resultado = mysql_query($consulta,$conex);
    while ($Objeto = mysql_fetch_object($resultado))
    {
    $Correo = $Objeto->Correo;
    $Persona = $Objeto->NombreContacto;
    enviar($Correo, $Persona);
    actualiza($Correo);
    }
    mysql_free_result($resultado);
    mysql_close($conex);

    ?>


    you may execute this program in the command line as :
    root@localhost # php senmassive.php



    Quote Originally Posted by mic2005
    i have designed a site that allows a user to input their email address to subscribe to a mailing list. but i am having several problems creating the page that sends emails to all the users that are in my newsletter table. the page has a text box to allow subject change and another text box to allow the bodytext to be inputted.

    any help would be greatly recieved.

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •