Moved to a new machine and script stopped working

This forum is for discussing Mailtraq's Scripting features. Get help with Mailtraq scripts, templates and external ActiveX scripting.

Moved to a new machine and script stopped working

Postby marcw » Sat Sep 27th, 2014 1:34pm

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?
Marc Wilson

Cleopatra Consultants Limited
User avatar
marcw
 
Posts: 42
Joined: Thu Dec 30th, 2004 10:05am
Location: Tarporley, Cheshire, UK

Re: Moved to a new machine and script stopped working

Postby Elric Pedder » Mon Sep 29th, 2014 10:42pm

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?
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Moved to a new machine and script stopped working

Postby marcw » Sat Oct 11th, 2014 9:20pm

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.
Marc Wilson

Cleopatra Consultants Limited
User avatar
marcw
 
Posts: 42
Joined: Thu Dec 30th, 2004 10:05am
Location: Tarporley, Cheshire, UK


Return to Mailtraq Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron