Author Topic: Where's the .CGI script for handling removal messages??  (Read 1598 times)

john193

  • Posts: 55
    • View Profile
Where's the .CGI script for handling removal messages??
« on: March 12, 2007, 12:43:23 pm »
Hi Dan,

You specify in the online manual....

An email alias allows ListMail to forward bounced, signup, and removal messages to the appropriate CGI scripts (the ones you just uploaded).

Unfortunately the only CGI scripts I uploaded was bounce.cgi, and signup_list1.cgi and signup_list2.cgi  --- I am not sure I ever saw any script which deals specifically with removal messages...

Did I miss something ?

Christopher

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Where's the .CGI script for handling removal messages??
« Reply #1 on: March 12, 2007, 05:17:44 pm »
Christopher,

No, you didn't - I did!  I removed the script from ListMail due to the fact that it is unreliable and can cause you complaints.  I found people frequently subscribing using a catch-all address that cannot be easily sent "From".  In the interest of everyone's benefit I removed the script, however here it is if you want to use it!
Code: [Select]
#!/usr/bin/perl
# ListMail remove.cgi - Unsubscribe by email.
#
# You must configure this script for it to work.
#
# Place the script in your "public_html/cgi-bin" directory.  You may need multiple copies of
# this script with different filenames / email alias addresses if you want to remove users from
# individual lists or different sets of lists.  Alternately, you can just specify all and the
# user will be removed from all lists with 1 email.

# SET this to your ListMail URL, NO trailing slash
$listmail_url = "http://www.DOMAIN.com/mail";

# SET the variable $list to one of the following:

# single list
# $list = '1';

# multiple lists
# $list = '1,3,2';

# all lists (default)
$list = 'all';

# usually works as default (may be /usr/local/bin/wget or other)
$http_program = "/usr/bin/wget -O - " . $listmail_url . "/remove.php";

# begin script

# encode function
sub encode {
  my $str = shift || '';
  $str =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
  $str;
}

# get piped message
$email = '';
while($line=<>){
 $email = $email . $line;
}

if($email){
 # process msg, grab email address and first / last name, if possible
 # find To:
 $searchstr = 'From: ';
 $strpos = index($email,$searchstr);

 if($strpos>=0){
  $thestr = substr($email,$strpos+length($searchstr),length($email));
  $npos = index($thestr,"\n");
  if($npos>=0) {
   # get email
   $thestr = substr($thestr,0,$npos);
   $lbpos = index($thestr,'<');
   if($lbpos>=0){
    $rbpos = index($thestr,'>');
    $em = substr($thestr,$lbpos+1,$rbpos-$lbpos-1)
   } else {
    $justmail = 1;
    $em = $thestr;
   }
   # check for name spaces
   $spos = index($thestr,' ');
   if($spos>=0) { $justmail = ''; } else { $justmail = 1; }

   if($justmail ne 1){
    # get name
    $name = substr($thestr,0,$lbpos-1);
    # strip quotes
    $name =~ s/\"//g;
    $spos = index($name,' ');
    if($spos>=0){
     $fn = substr($name,0,$spos);
     $ln = substr($name,$spos+1,length($name)-$spos-1);
    }
   }

   # sign up
   $sys_cmd = $http_program . "\\?cgi=1\\&list=$list\\&email=$em";
   if($fn ne '') { $sys_cmd = $sys_cmd . "\\&fname=$fn"; }
   if($ln ne '') {
    $ln = encode($ln);
    $sys_cmd = $sys_cmd . "\\&lname=$ln";
   }
   system($sys_cmd . " > /dev/null 2> /dev/null");
   # notify in php
  }
 }

}

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

john193

  • Posts: 55
    • View Profile
Where's the .CGI script for handling removal messages??
« Reply #2 on: March 13, 2007, 04:13:05 am »
Hi Dean,

Got your script for remove.cgi ... but let me see if I understand.

If I don't include the remove.cgi script on the site (cgi-bin folder) then how exactly can anyone remove themselves from a list ? and if they can remove themselves is it strictly on a list by list basis ?

If it's simply by a list by list basis... that's ok with me.  Just curious.

Christopher

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Where's the .CGI script for handling removal messages??
« Reply #3 on: March 13, 2007, 05:21:05 pm »
Christopher,

Sorry about the delay - I really need to get the FAQ online!  The usual way to allow your users to opt-out is by including a message code of the type "Remove Link" in your messages.  By default one named !remove is created under Message Codes > Global Codes

Please let me know if I can be of further assistance!
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting