Author Topic: Repeat attempts to unsubscribe - Is this a small bug ?  (Read 3428 times)

Decka

  • Posts: 20
    • View Profile
Repeat attempts to unsubscribe - Is this a small bug ?
« on: December 15, 2004, 10:12:55 pm »
I'm a new user to ListMail, so I'm not sure if what I have found is a bug with Listmail or me. I noticed while doing some setup tests, that if you unsubscribe using the clickable link in a received email that it's possible to continue to repeat this process and still keep getting the "retrieved" name from database message.

It does not matter how many times you click on the auto unsubscribe link in the email, Listmail keeps finding the subscriber even though the name is no longer in the database. Doesn't sound possible does it.

It also repeatidly sends out the Listmail notification that the same user has unsubscribed. It does not bring up the 'user not found can you contact web site admin to remove manually'.

It's not a major problem, just a bit wierd !  :shock:

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #1 on: December 19, 2004, 11:42:35 pm »
I wonder if you have the option "Keep removed users in database but don't mail" enabled for your list.  Do you?

If so, then the users information could still be retrieved and a fix should definitely be made.  I thought I had performed the user check based on the Active status but could have made a mistake.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Same problem...
« Reply #2 on: December 20, 2004, 07:18:12 am »
Hi Dean,

I've noticed this same problem coming up, and I do have 'Keep removed users in database but don't mail' turned on....  can you please post the fix for this?
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #3 on: December 21, 2004, 01:16:49 pm »
remove.php line 51 should read:

Code: [Select]
 $cmd = "select id,list,fname,lname,email from $utable where uid = '$u' and cnf = '1'";
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
which line is that??
« Reply #4 on: December 21, 2004, 05:43:17 pm »
Dean,

Could you please post the original line it is replacing, I've made modifications to remove.php and my line 51 is nothing like that...
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #5 on: December 21, 2004, 11:26:29 pm »
Here is the original line:

Code: [Select]
$cmd = "select id,list,fname,lname,email from $utable where uid = '$u'";
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Decka

  • Posts: 20
    • View Profile
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #6 on: December 23, 2004, 05:54:14 am »
Hi,
Dean, I have only just checked back on the replies to my posting and yes I did set the option to keep in database but not email. I have replaced the line of code in remove.php as suggested but I still get the same response when trying to unsubscribe a user who has already unsubscribed.

I have also unticked the keep user in database option but still I get the same responses as if the subscriber still exists.

Decka

  • Posts: 20
    • View Profile
Repeat attempts to unsubscribe
« Reply #7 on: December 23, 2004, 06:06:31 am »
Hi,

In my last post I forgot to mention that Listmail also sends me the unsubscriber notices by email of those who have unsubscribed to these repeat attempts.

It sends out the unsubscribed email every time the same user unsubscribes.

The subscribers are no longer in the database. At least not ones you can see in the database when you look in the Users.

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
is this the correct line number/module?
« Reply #8 on: December 27, 2004, 10:39:54 am »
DW,

Please check that, I found line 51 of code and noticed that the reference to remove in my EMAIL links turns out like this:
Code: [Select]

http://mydomain.com/mail/rem.php?u=445f175


This indicates that rem.php is the module, and not remove.php?

I made the change of code in rem.php and get a correct reply now that the user is deleted - do I need to make this change to remove.php also? Please let me know.
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #9 on: December 29, 2004, 11:17:54 am »
Oh, right.  I copied remove.php to rem.php so that the program would still be compatible with older remove links.  Later on, I was going to remove remove.php completely because it adds to the SpamAssassin score of your messages.  You should only need to make the change in rem.php but can do it in both if you like.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Creating a jump start for the queue mailer via cron...
« Reply #10 on: December 29, 2004, 03:32:13 pm »
DW,

THanks for the reply, can you please give me a little info on how the 'queue' works?  

I cannot wait any longer for your update and must get this handled ASAP, I'm going to have to write my own background mail handler that jump starts the domail.php queue in PERL via a CRON job.

If you can give me a little insight into it, it will be very helpful...

I see this code in admin.php - the send mail queue loop - this is what I will use to create another module that will handle jump starting the queue by running from CRON every 15mins or so?  I also see that records are created in lm_sendq (the queue table) - I see those records are deleted one as a time as they are sent - so my guess is I only need to check mrows (number of rows) in lm_sendq and if there are any I can jump start those - IF that number stays the same the next time I run my CRON job - in other words if I wait 15 minutes (and I have saved num_rows) in lm_sendq and it's the same when CRON runs again, I should assume that the queue is stuck and start it up again - how's that sound?

Does that sound right, and any insight you can give on other code I should look at would be helpful...  I really don't have any other alternative as I have to get this working - I can't sit here and press RESUME all day long with large sendings...

Thanks,
-Brett

Code: [Select]

 // queue loop !!!

 // read from lm_sendq and process..
 $cmd = "select id,mtype,uid,mid,xtra from $otable where bat = '$batch'";
 $mrows = @mysql_query($cmd);
 if($sqldebug) echo "CMD=<b>$cmd</b><br>";

 // display send box
 $nmails = @mysql_num_rows($mrows);
 $txsize = strlen($nmails);

 if($dayo || $solo) {
   echo "<center></span><span id=delaymsg style=\"font: italic 8pt helvetica; display: none\">Delaying.. Please wait..</span><br><span class=table_inside_normal>If your mailing stops for any reason, close the window or <input class=button type=button onclick=\"hopto('./domail.php?resume=1&batid=$batch&list=$list')\" name=bs value=\"click here\">.  Do NOT Refresh!<br><br>Sending Mail&nbsp;<input type=text name=disp size=$txsize value=0>&nbsp;of&nbsp;$nmails..</span><br>";
  flush();
 }
 if(!$mailcount) $mailcount = 50;

 if(@mysql_num_rows($mrows)>0){

  while(list($oid,$mtype,$uid,$msgid,$xtra)=mysql_fetch_row($mrows)){

   $skiptonext = '';
   $error = '';

   if($mtype<>'5'){
    // get user send vars
    $cmd = "select uid,list,fname,lname,email,htmail,bounces from $utable where id = '$uid'";
    $urow = mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($unid,$mlist,$fname,$lname,$email,$htmail,$bounces)=mysql_fetch_row($urow);
    if(strpos($email,'@aol.com')>0 && !$html_to_aol) $aol = 1; else $aol = '';

    // echo "UID=$uid UNID=$unid  EMAIL=$email<br>";
   }

   // get message
   if($mtype=='1' && (!$solo || $xid == 'resume')){
    $cmd = "select subject,content,htcontent,fattach from $ttable where id = '$msgid'";
    $msgrow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";

    list($subj,$msg,$htmsg,$fatt) = @mysql_fetch_row($msgrow);
   }
   if($mtype=='2'){
    // followup
    $cmd = "select subject,content,htcontent,fattach from $ftable where id = '$msgid'";
    $msgrow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($subj,$msg,$htmsg,$fatt) = @mysql_fetch_row($msgrow);
   }

   if($mtype=='3'){
    // welcome message
    $cmd = "select welsubj,welcom,welcht,welcf from $ltable where list = '$mlist'";
    $msgrow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($subj,$msg,$htmsg,$fatt) = @mysql_fetch_row($msgrow);
   }

   if($mtype=='4'){
    // confirm message
    $cmd = "select cnfsubj,cnfmesg,cnfht,cnff from $ltable where list = '$mlist'";
    $msgrow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($subj,$msg,$htmsg,$fatt) = @mysql_fetch_row($msgrow);
   }

   if($mtype=='5'){
    $cmd = "select list from $utable where id = '$uid'";
    $urow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($mlist)=@mysql_fetch_row($urow);

    // admin email.. msgtype in sendq $xtra
    $msgtype = $xtra;

    if($msgtype=='bounce' || $msgtype=='daily'){
     $xmails = explode(';',$admmail);
     $admmail = $xmails[0];
     $email = $admmail;
     // saved table
     $cmd = "select subject,content,htcontent,fattach from $stable where id = '$msgid'";
     $msgrow = @mysql_query($cmd) or die("mysql select prob");
     if($sqldebug) echo "CMD=<b>$cmd</b><br>";
     list($subj,$msg,$htmsg,$fatt) = @mysql_fetch_row($msgrow);
     $cmd = "delete from $stable where id = '$msgid'";
     @mysql_query($cmd);
     if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    }
    $today = date("D M jS H:m T");

    if($msgtype=='daily'){ $subj = "Dailymail - $today"; }

    // get ip and ref url
    global $REMOTE_ADDR;
    global $HTTP_REFERER;
    $ipaddr = $_SERVER['REMOTE_ADDR']; if(!$ipaddr) $ipaddr = $REMOTE_ADDR; if(!$ipaddr) $ipaddr = "Unknown";
    $refurl = $_SERVER['HTTP_REFERER']; if(!$refurl) $refurl = $HTTP_REFERER; if(!$refurl) $refurl = "Unknown";
    $iphost = @gethostbyaddr($ipaddr);

    if(!$sendn) $sendn = 'ListMail Notification';
    $sende = $errmail;
   } else {
    // not admin msg, continue
    $cmd = "select sendn,sende from $ltable where listnum = '$mlist'";
    $lrow = @mysql_query($cmd);
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    list($sendn,$sende)=@mysql_fetch_row($lrow);
//    echo "got list settings<br>"; flush();
   }
   $y++;

   // send the message
   if($subj && $msg){
//    echo "processing message...<br>"; flush();

    // process message codes
    if($mtype<>'5'){
     $xsubj = processmsg($uid,$subj,'0',$mtype,$msgid);
     $xmsg = processmsg($uid,$msg,'0',$mtype,$msgid);
     if($aol){
      // $xmsg = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a href=\"$1\">$1</a>",$xmsg);
      // $xmsg = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$xmsg);
     }
     $xhtmsg = processmsg($uid,$htmsg,'1',$mtype,$msgid);
    } else {
     // echo "SUBJ=$subj,MSG=$msg.<br>";
     $xsubj = $subj; $xmsg = $msg; $xhtmsg = $htmsg;
    }

    // init MIME message
    $mail = new html_mime_mail();

    // html message
    if($htmsg && $htmail == '1' && !$aol) $mail->add_html($xhtmsg, $xmsg, '');

    // text message
    if(($msg && !$htmsg) || ($msg && $htmsg && ($htmail == '0' || $aol))) $mail->add_text($xmsg);

    // add file attachments
    if($fatt) {
     $xfatt = explode(',',$fatt);
     while(list($key2,$filen) = each($xfatt)){
      setfiletype($filen); // set atype and etype
      global $atype;
      global $etype;
      if(!$atype) $atype = 'application/binary';

      // check file exists before adding
      $result = file_exists("./attach/" . $filen);

      if($result==true){
       $attachment = $mail->get_file("./attach/$filen");
       $mail->add_attachment($attachment, $filen, $atype, $etype);
      }
     }
    }

    // build final message
    // default charset for MIME message, improve this.
    $dcharset = "iso-8859-1";
    if($charset) $bchar = $charset; else $bchar = $dcharset;

    $build_params = array();
    $build_params['html_charset'] = $bchar;
    $build_params['text_charset'] = $bchar;

    // $build_params['text_wrap'] = '30';
    $mail->build_message($build_params);

    // testing!!
    /* $body = $mail->output;
    echo "<br><Br>".nl2br($body); */

    // build full name for to: field
    if($mtype=='5') $fulln = 'ListMail Admin';
     else {
     $fulln = $fname;
     if($lname && $lname<>'0') $fulln .= ' ' . $lname;
    }

    // final message

    $index = 0;
    // $bad_rcpt = array();
    // $smtp_from = $errmail;
    // $smtp->Sender = $errmail;
    // calculate date/time

    $tz = date("Z");
    $tzs = ($tz < 0) ? "-" : "+";
    $tz = abs($tz);
    $tz = ($tz/3600)*100 + ($tz%3600)/60;
    $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);

    $body = $mail->output;
    $headers = $mail->headers;
    $header = '';

    $crlf = "\n";
    if($smtpsend) $header .="Date: $date$crlf";
    $header .="From: \"$sendn\" <$sende>$crlf";
    if($smtpsend)
     if($fulln) $header .= "To: \"$fulln\" <$email>$crlf";
      else $header .= "To: $email$crlf";

    if($smtpsend) $header .="Subject: $xsubj$crlf";
    if(!$smtpsend) $header .= "Return-Path: $errmail$crlf";
    $header .= "MIME-Version: 1.0$crlf";
    while(list($key2,$data) = each($headers)){
     // $data1 = str_replace("\r","\\r",str_replace("\n","\\n\n",$data));
     // echo "data1=<b>$data1</b><br>";
     $header .= $data.$crlf;
    }
    $header .="X-Mailer: ListMail v$ver";

    if($smtpsend) $header .= "$crlf";

    if(($htmsg && $htmail && !$aol) || $fatt){
     $header .= $crlf."This is a multipart message in MIME format.";
     if($smtpsend) $header .= $crlf.$crlf;
    } else
    if($smtpsend) $header .= "$crlf";

    // final send
//    echo "going to final send<br>"; flush();
    if($smtpsend){

//     echo "smtpsend..<br>"; flush();

     if($demo <> 'yes') {

      // need to POP check?
      if($mtpchk){
       $now = date("YmdHis");
       $diff = $now - $starttime;
       if($diff > $mtpdelay){
        $asock = fsockopen($mtphost, $mtpport);
        if(!$asock) $error = 1; else $error = '';
        if(!$error){
         // connected!
         $srvmsg = fgets($asock, 1024);
         $lastmsg = substr($srvmsg, 0, 1);
         if ($lastmsg <> "+") $error = 1; else $error = '';
         if(!$error){
          // send user
          fputs($asock, "USER $mtpuser\r\n");
          $srvmsg = fgets($asock, 1024);
          $lastmsg = substr($srvmsg, 0, 1);
          if ($lastmsg <> "+") $error = 1; else $error = '';

          // send pass
          fputs($asock, "PASS $mtppass\r\n");
          $srvmsg = fgets($asock, 1024);
          $lastmsg = substr($srvmsg, 0, 1);
          if ($lastmsg <> "+")$error = 1; else $error = '';
          // if($error) echo " Failed!<br>"; else echo " Verified!<br>";

          if(!$error){
           // check # of messages
           fputs($asock, "STAT\r\n");
           $srvmsg = fgets($asock, 1024);
           $lastmsg = substr($srvmsg, 0, 1);
           if ($lastmsg <> "+") $error = 1;
          }
          // QUIT
          fputs($asock, "QUIT\r\n");
          $srvmsg = fgets($asock, 1024);
          $lastmsg = substr($srvmsg, 0, 1);
          if ($lastmsg <> "+") $error = 1;
          sleep(4);
         }
        } // else failed connect
        $starttime = $now;
       }
      }

//      echo "check smtp delay..<br>"; flush();

      // check smtp delay
      $mtimer++;
      if($mtimer > $mtdelay) {
       fputs($ssock, "QUIT\r\n");
       $srvmsg = @fgets($ssock, 1024);
       $reconnect = 1;
       $skiptonext = '';
       $mtimer = 1;
      }
      if(!$ssock) $reconnect = 1;

//      echo "check reconnect.. value=$reconnect<br>"; flush();

      if($reconnect || !is_resource($ssock)){
       if($bugs){ echo "reconnecting!"; flush(); }
       // (re)connect to smtp
       $ssock = fsockopen($mthost, $mtport) or die('could not open socket with fsockopen()');
       if(!$ssock) $error = 1; else $error = '';
       if(!$error){
        // connected!
         $srvmsg ='';

        $srvmsg = getsmtpmsg($ssock);
        if($bugs){ echo "CONNECTEDmsg=".nl2br($srvmsg); flush(); }

        if(!$error){

         if(!$error){
          $hhost = @getenv('HTTP_HOST');
          if(!$hhost) $hhost = 'listmail';
           else {
           // echo substr($hhost,0,4);
           if(substr($hhost,0,4)=='www.')
            $hhost = substr($hhost,4,strlen($hhost)-1);
          }

          // send ehlo
          fputs($ssock, "EHLO localhost\r\n");
          $srvmsg = getsmtpmsg($ssock);
          if($bugs){ echo "EHLOmsg=".nl2br($srvmsg); flush(); }
          $lastmsg = substr($srvmsg, 0, 3);
          if ($lastmsg <> "250"){
           if($lastmsg=="500"){
            if(!$helohost) $helohost = 'localhost';
            fputs($ssock, "HELO $helohost\r\n");
            $srvmsg = getsmtpmsg($ssock);
            if($bugs){ echo "HELOmsg=".nl2br($srvmsg); flush(); }
            $lastmsg = substr($srvmsg, 0, 3);
            if($lastmsg <> "250") $error = 1; else $error = '';
           } else $error = 1;
          } else $error = '';
         }

         // check pipelining, need to finish this
         if(strpos($srvmsg,'PIPELINING')>0) $pipeline = 1; else $pipeline = '';
//         $pipeline = ''; echo "PIPELINING OFF!<br>"; flush();

         // auth
         if($mtauth && strpos($srvmsg,'AUTH LOGIN')>0){
          // EHLO says auth is good
          fputs($ssock, "AUTH LOGIN\r\n");
          $srvmsg = getsmtpmsg($ssock);
          if($bugs){ echo "AUTHmsg=".nl2br($srvmsg); flush(); }
          $lastmsg = substr($srvmsg, 0, 3);
          if ($lastmsg <> "334") $error = 1; else $error = '';

          if(!$error){
           // send username
           fputs($ssock, base64_encode($mtuser)."\r\n");
           $srvmsg = getsmtpmsg($ssock);
           if($bugs){ echo "AUTHUSERmsg=".nl2br($srvmsg); flush(); }
           $lastmsg = substr($srvmsg, 0, 3);
           if ($lastmsg <> "334") $error = 1; else $error = '';

           if(!$error){
            // send password
            fputs($ssock, base64_encode($mtpass)."\r\n");
            $srvmsg = getsmtpmsg($ssock);
            if($bugs){ echo "AUTHPASSmsg=".nl2br($srvmsg); flush(); }
            $lastmsg = substr($srvmsg, 0, 3);
            if ($lastmsg <> "235") $error = 1; else $error = '';
           }
           if($error) echo "Bad password<br>";
          } else {
           echo "Username not accepted.<br>";
          }
          $noplain = 1;
         } else {
          // echo "AUTH command not accepted.<br>";
         }
         // auth plain
         if($mtauth && strpos($srvmsg,'AUTH PLAIN')>0 && !$noplain){
          // EHLO says auth is good
          fputs($ssock, "AUTH PLAIN ".base64_encode("\0".$mtuser."\0".$mtpass)."\r\n");
          // echo "XXXX=AUTH PLAIN ".base64_encode("\0".$mtuser."\0".$mtpass)."\r\n<br>";
          $srvmsg = getsmtpmsg($ssock);
          if($bugs){ echo "AUTH(plain)msg=".nl2br($srvmsg); flush(); }
          $lastmsg = substr($srvmsg, 0, 3);
          if ($lastmsg <> "235") $error = 1; else $error = '';
          if($error){  if($solo||$dayo) echo "User/Pass not accepted.<br>"; }
         }
        } else {
         echo "EHLO failed! ($srvmsg)<br>";
        }
       } else {
        echo "Connect to server <b>$mthost</b>:<b>$mtport</b> failed.<br>";
       }
       $reconnect = 0;
      } // end !connected

      // send the mail     !
//      echo "send the mail!<br>"; flush();

      // from
      if(!$pipeline){
       fputs($ssock, "MAIL FROM: <$errmail>\r\n");
       $srvmsg = fgets($ssock, 1024);
       if($bugs){ echo "MAILFROMmsg=$srvmsg.<br>"; flush(); }
       $lastmsg = substr($srvmsg, 0, 3);
       if ($lastmsg <> "250") $error = 1; else $error = '';

       if(!$error){
        // check recipient

        // echo "EMAIL=$email..<br>";
        fputs($ssock, "RCPT TO: <$email>\r\n");
        $srvmsg = getsmtpmsg($ssock, 1024);
        if($email=='') $srvmsg = '';
        if($bugs){ echo "RCPT TO: &lt;$email&gt; &nbsp;RCPTmsg=".nl2br($srvmsg); flush(); }

//        if($email == 'badtest@email.com'){ echo " WAS: $srvmsg<br>"; $srvmsg = '550 BADTEST'; }

        $lastmsg = substr($srvmsg, 0, 3);


        if ($lastmsg <> "250") $error = 1; else $error = '';
       }
       if($error){
        // reset
        fputs($ssock, "RSET\r\n");
        $srvmsg = getsmtpmsg($ssock, 1024);
        if($email=='') $srvmsg = '';
        if($bugs) echo "RSETmsg=$srvmsg.<br>";
        $error = 1;
        if($srvmsg<>'') $skiptonext = 1; else $srvmsg = "(Server is not responding to requests after sending ".($y-1)." messages.)<br>";
        if($bugs){ echo "Bad RCPT response ($email), skipping.<br><br>"; flush(); }
       }

       if(!$error){
        // start data
        fputs($ssock, "DATA\r\n");
        $srvmsg = fgets($ssock, 1024);
        if($bugs){ echo "DATAmsg=$srvmsg.<br>"; flush(); }
        $lastmsg = substr($srvmsg, 0, 3);
        if ($lastmsg <> "354") $error = 1; else $error = '';
       }
      } else {

       // SMTP pipelining
/*       echo "fputs($ssock, \"MAIL FROM: <$errmail>\r\n\");";
       echo "fputs($ssock, \"RCPT TO: <$email>\r\n\");";
       echo "fputs($ssock, \"DATA\r\n\");"; */

       fputs($ssock, "MAIL FROM: <$errmail>\r\n");
       fputs($ssock, "RCPT TO: <$email>\r\n");

       $srvmsg = fgets($ssock,1024);
       if($bugs){ echo "PIPELINE-FROMmsg=$srvmsg.<br>"; flush(); }

       $lastmsg = substr($srvmsg, 0, 3);
       if ($lastmsg <> "250") $error = 1; else $error = '';

       if(!$error){
        $srvmsg = getsmtpmsg($ssock,1024);
        if($bugs){ echo "RCPT TO: &lt;$email&gt;<br>RCPTmsg=".nl2br($srvmsg); flush(); }

        // DEBUG
        if($email == 'bad@listmailpro.com'){ echo " WAS: $srvmsg<br>"; $srvmsg = '550 BADTEST'; }

        $lastmsg = substr($srvmsg, 0, 3);

        if ($lastmsg <> "250") {
         $error = 1;
        } else $error = '';

        if($lastmsg == '550'){
         fputs($ssock, "RSET\r\n");
         $srvmsg = fgets($ssock,1024);
         if($bugs){ echo "RSETmsg=$srvmsg<br>"; flush(); }
         $error = 1;  $skiptonext = 1;
         if($bugs){ echo "Bad RCPT response ($email), skipping.<br><br>"; flush(); }
        } else $error = '';

        if(!$error){
         fputs($ssock, "DATA\r\n");
         $srvmsg = fgets($ssock,1024);
         if($bugs){ echo "DATAmsg=$srvmsg.<br>"; flush(); }
         $lastmsg = substr($srvmsg, 0, 3);
         if ($lastmsg <> "354") $error = 1; else $error = '';
        }
       }
      }

      // data - both send methods
      if(!$error){
       // start data
       $themesg = $header.$body;
       $themesg = str_replace("\r\n","\n",$themesg);
       $themesg = str_replace("\n","\r\n",$themesg);
   //    echo '['.htmlspecialchars('.').']';
//       $themesg = str_replace("=\r\n.",".=\r\n",$themesg);
//       $themesg = str_replace("=0D\r\n.",".=0D\r\n",$themesg);

       $themesg = str_replace("\r\n.","\r\n..",$themesg);

       $xmsg = str_replace('<','&lt;',$themesg);
       $xmsg = str_replace('>','&gt;',$xmsg);
       // echo nl2br($xmsg);

       fputs($ssock, $themesg."\r\n.\r\n");
       $srvmsg = fgets($ssock, 1024);
       if($bugs){ echo "SENDmsg=$srvmsg.<br><br>"; flush(); }
       $lastmsg = substr($srvmsg, 0, 3);
       if ($lastmsg <> "250") $error = 1; else $error = '';
      }
     }

// BAS MOD - 05/06/04 - THROTTLE CODE, pause 25 seconds every 100 Emails
// 05/07/04 - found out that this code did not increase click throughs
// maybe have to extend the throttle delay longer, or the emails
// are getting sent out, and just blocked or no interest from users
// 07/08/04 - CHECK THAT, it is working, search for Throttle on the forums at
// LIST MAIL PRO for more information
if(($y % '100')==0 && $y <> sizeof($sendq)) sleep(25);    
// BAS MOD END
     
    } else {
     // use php mail()
     $body = str_replace("\r\n","\n",$body);

     if($fulln) $email = "\"$fulln\" <$email>";

     if ($demo <> 'yes'){

      if($phpmailf) mail($email,$xsubj,$body,$header,"-f$errmail");
       else mail($email,$xsubj,$body,$header);
     }

     // if($mailed) echo "mailed ok.<br>"; else echo "mailed failed.<Br>";
     // delay
     sleep(($del1)*(.001));
     if(($y % $del3)==0 && $y <> sizeof($sendq) && $mtype <> '3') {
      echo "<script>delaymsg.style.display=\"\"</script>";
      flush();
      sleep(($del2)*60);
      echo "<script>delaymsg.style.display=\"none\"</script>";
     }
    }
   } else {
    // !message
    echo " Message has no body / subject!<br>";
   }
//   echo "next??!<br>";
   if($error && !$skiptonext){
//    echo "sending error!! ";
    echo "<span class=status_text style=\"color: red\"><br>Sending error.  Check your mail settings.<br><br></span><span class=status_text>Server said: ".nl2br($srvmsg)."<br></span><input class=button type=button onclick=\"hopto('./editconf.php?list=$list')\" name=tc value=\"Go To Config\"><br>";
    exit;
   }
   $cmd = "delete from $otable where id = '$oid'";
   mysql_query($cmd) or die('problem with DELETE otable query.<br>');
   // optimize table every 1000
   if($y % 1000 == 0 || $y == $nmails) mysql_query("optimize table $otable");
   // increase display count
   if($dayo || $solo){
//    echo "checking display count .. y=$y .. mailcount=$mailcount<br>";
    //     echo "y=$y mailcount=$mailcount DIV=" . ($y % $mailcount)."<br>";
    if($sqldebug) echo "CMD=<b>$cmd</b><br>";
    if($y % $mailcount == 0 || $y == $nmails) echo "<script>this.disp.value='$y'</script>\n";
//    echo "end if<br>";
   }
//   echo "no sending error!  end loop! next!<br>";
   flush();
  }
 } else {
  echo "Called domail with no messages in queue, aborting.<br>";
 }

 if(!$error && $smtpsend){
  // start data
  fputs($ssock, "QUIT\r\n");
  $srvmsg = fgets($ssock, 1024);
  if($bugs) echo "QUITmsg=$srvmsg.<br>";
  $lastmsg = substr($srvmsg, 0, 3);
  if ($lastmsg <> "221") $error = 1; else $error = '';
 }
 // if(is_resource($ssock)) echo "<b>(Q) server is connected</b><br>"; else echo "<b>(Q) server is not connected</b>";
 if($smtpsend) mysql_query("optimize table $qtable");
 return true;
} // end domail
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #11 on: December 30, 2004, 02:33:50 am »
If a cron task resumes before the mailing is complete it can cause duplicate messages.

What you will need to look for is the $resume variable in domail.php.  The code within the if statement is the code that resumes a mailing.  Without modifying it you'd need a way to tell it which batch to resume, ie by selecting a single row from the lm_queue table.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #12 on: December 30, 2004, 07:35:03 am »
Hi Dean,

Quote
If a cron task resumes before the mailing is complete it can cause duplicate messages.


Well, I hope that my idea of checking the queue and seeing if the same number of records are there is accurate, and it would only start re-sending - IF the queue size stays the same for 15 mins, when the next CRON task runs?

Quote
What you will need to look for is the $resume variable in domail.php. The code within the if statement is the code that resumes a mailing. Without modifying it you'd need a way to tell it which batch to resume, ie by selecting a single row from the lm_queue table.


Ok, I'll have a look at that...  regarding which batch to resume, I can get that from lm_sendq, it has the batch ID in it, so I figure I'll just grab the first one, double check on resuming that batch, and then watch it for 15 mins when the next CRON job runs, if it's the same number of records, that is the batch I will 'resume'...   I won't choose another batch, until one batch is done - not the best way, but I don't mind waiting for batches - especially if it's all being done by CRON instead... that should allow enough time to get large batches (25K or more) out within 4-5 hours, and therefore to get at least 50K or more out overnight, when I'm sleeping :)

Let me know if that sounds 'workable' to you, as that is the way I intend to approach it, I know it's not truly the best - and your background module will be much better I'm sure...  BTW - when can we expect the upgrade?  Any further details on it's completion, how's it going?
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #13 on: December 30, 2004, 08:43:25 pm »
As I believe I mentioned in another post, I don't think the upcoming background sending option will help you.  Background sending, accomplished with "ignore_user_abort()", expects the PHP script / web page to keep running.  It appears that your server has a hard limit on the amount of time a PHP script can run.  

Your suggested method of checking if the queue has stalled is fine.  It's really the only way to do it.  15 mins is very reasonable and safe amount of time to check for changes.  I'm considering adding an "auto-resume" feature, similar to how you've approached it, in the near future.

I'm working on completing the update.  Thanks for your patience.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Repeat attempts to unsubscribe - Is this a small bug ?
« Reply #14 on: March 25, 2005, 07:03:09 pm »
This should no longer be an issue in v1.8
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting