Page 1 of 1

Moved to a new machine and script stopped working

PostPosted: Sat Sep 27th, 2014 1:34pm
by marcw
I have an autoresponder, based on Jim Hill's excellent code.

I've moved my Mailtraq instance to a new machine, and the script no longer functions.


Code: Select all
// Automatic Reply to Mail (autoresponder)
// -------------------------------------------------
// MAILBOX = Mailbox responding
//
// Type of autoresponse required?
// 1=Vacation, 2=Out-of-Office, 3=Return Headers, 4=General Purpose
{ auto := 1;
  SelectInMessage();
  auto_reply := WildcardMatch(Header("To"), "*" ++ MAILBOX ++ "*");
  If(auto_reply, auto_reply := Length(MsgGetSender()) > 3);
  If(auto_reply,
    Do(
      hdr_list := "Precedence,List-Id,List-Post,List-Help,List-Unsubscribe,List-Subscribe,List-Archive,X-Post-MessageClass",
      For(hdr_list, "hdr",
        If(Length(Header(hdr)) > 0, auto_reply := "FALSE")
      )
    )
  );
  If(auto_reply, auto_reply := Not(SameAddress(Header("Delivered-To"), AddressOf(MAILBOX)));
  If(auto_reply, auto_reply := Not(Length(Header("Subject")) = 0));
  If(auto_reply, auto_reply := Not(WildcardMatch(Header("Subject") ++ " ", "*Delivery Report*")));
  If(auto_reply,
    Do(
      If(auto <= 2,
        recip := MsgGetSender(),
        If(WildcardMatch(Header("Reply-To"), "*@*"),
          recip := AddressOf(Header("Reply-To")),
          If(WildcardMatch(Header("Sender"), "*@*"),
            recip := AddressOf(Header("Sender")),
            recip := AddressOf(Header("From"))
          )
        )
      ),
      box_list := "mailer-daemon,noc,request,postmaster,hostmaster,webmaster,abuse,newsmaster",
      For(box_list, "box",
        If(WildcardMatch(recip, "*" ++ box ++ "*"), auto_reply := "FALSE")
      )
    )
  );
  If(auto_reply,
    Do(
      block_list := DBListRecords("auto-" ++ MAILBOX ++ ".blk"),
      If(Length(block_list) > 0,
        For(block_list, "block",
          If(WildcardMatch(recip, block), auto_reply := "FALSE")
        )
      ),
      If(Not(HostOf(recip) = HostOf(MsgGetSender())), auto_reply := "FALSE")
    )
  )
}{
If(auto_reply,
  Do(
    db := "auto-" ++ MAILBOX ++ ".dbq",
    If(DBRecordExists(db, recip),
      auto_reply := "FALSE",
      Do(
        DBWrite(db, recip, "From", Header("From")),
        DBWrite(db, recip, "Date", Now()),
        DBWRite(db, recip, "Msg-Id", Header(Message-ID)),
        DBWrite(db, recip, "Subject", Header("Subject"))
      )
    )
  )
)
}{
If(auto_reply,
  Do(
    delto_list := Header("Delivered-To"),
    delto_list := If(Length(delto_list) > 0, delto_list ++ ",") ++ AddressOf(MAILBOX),
    delto_head := "",
    i := 1,
    While((i <= ListCount(delto_list)) & (i < 10),
      Do(
        to := Params(delto_list, ",", i),
        delto_head := If(Length(delto_head) > 0, delto_head ++ "\nDelivered-To: ") ++ to,
        i := i + 1
      )
    ),
    user := GetSystemVar("/mailslots/" ++ MAILBOX ++ "/Description"),
    SelectOutMessage(),
    SetHeader("Delivered-To", delto_head),
    SetHeader("Precedence", "bulk"),
    SetHeader("From", "\q" ++ user ++ "\q <" ++ AddressOf(MAILBOX) ++ ">"),
    SetHeader("To", recip),
    SetHeader("Reply-To", AddressOf("postmaster")),
    SetHeader("Subject", "Autoresponse from " ++ user),
    MsgSetSender(""),
    DeleteHeader("Errors-To")
  ),
  Do(
    SelectOutMessage(),
    SetHeader("X-Route", "dev/nul")
  )
)
}
This is an autoresponse from <{ AddressOf(MAILBOX) }> to your message:-

      Subject:   { SelectInMessage(); Header("Subject") }
      From   :   { Header("From") }
      Date   :   { Header("Date") }
      Msg-Id :   { Header("Message-ID") }

{
  msgfile := "auto-" ++ MAILBOX ++ ".txt";
  a := OpenFile(msgfile);
  While(Not(EOF(a)),
    Read(a);
  );
  CloseFile(a)
}


The database path is different (it's now on D and not C, for instance) but it's finding that for other purposes.
Any suggestions about where to look for the problem?

**UPDATE** I've just looked in more detail at the dialogue, and I see there's a new "already responded" pane and a "do not respond" pane.
Does this mean I no longer need the script - indeed, cannot use the script?

Re: Moved to a new machine and script stopped working

PostPosted: Mon Sep 29th, 2014 10:42pm
by Elric Pedder
The script system hasn't changed so I don't think the script would fail to work but as I understand it you can achieve at least some of the goals without the script now. What exactly doesn't work?

Re: Moved to a new machine and script stopped working

PostPosted: Sat Oct 11th, 2014 9:20pm
by marcw
It doesn't update the file any more with the names it's replied to. It appears not to need to do so, as I discovered there's an "already replied" pane (as well as a "never respond" pane, which is useful - I put things like bounce*@* in there). It gathered a bunch of addresses, but in the pane, not in the file.

I just wonder how it can execute and send a response but not update the file.