Autorespond to email other than sender's?

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

Autorespond to email other than sender's?

Postby leo » Thu Jan 11th, 2007 7:09pm

:roll: I would like Mailtraq to autorespond to email address other than sender's? Basically I want to receive email notifications on my cell phone (e.g. 123456890@mobilphoneco.com) or in another external email when there is new mail in my mailbox? Would be nice to include only "from" and "subject" as part of information.

I was also wondering if it is possible to autorespond only when message is from particular sender or contains particular subject. Please help.
leo
 
Posts: 4
Joined: Thu Sep 15th, 2005 2:56pm

Re: Autorespond to email other than sender's?

Postby Martin Clayton » Thu Jan 18th, 2007 12:40pm

Hi,
leo wrote:I would like Mailtraq to autorespond to email address other than sender's? Basically I want to receive email notifications on my cell phone (e.g. 123456890@mobilphoneco.com) or in another external email when there is new mail in my mailbox? Would be nice to include only "from" and "subject" as part of information.

You could test the template below. To set-up for a mailslot called "test", use the Templates dialog (at Options, Scripts and Templates...) to Subclass the autoresponder, then Edit the 'test' file replacing all content with:

Code: Select all
<@LANGUAGE=JavaScript@>
<%
  // autoresponder template (autoresponder~{mailslot-name}.tpl)
  // Martin Clayton: Jan 07
  // - Send email notification on new mail
  // - Optionally, only notify when headers match contents
  //   specified in a text file

  // Custom vars --------------------------

  // output message properties
  var OutputMsgAddress = "123456890@mobilphoneco.com";
  var OutputMsgSubject = "New mail notification";
  var OutputMsgFrom = "postmaster@my-domain.com";
 
  // Only alert when 1+ header matches entries in config file?
  var NotifyWhenHeadersMatch = true;
 
  // File for header matches
  var HdrMatchFile = "auto-notify~test.txt";

  // Must be in the database folder, format:

  // [From]
  // pm@gov.uk
  // Farraday, Jack
  //
  // [Subject]
  // Auto notification test
  // Meeting
  //
  // [To]
  // abuse@

  // --------------------------------------

  var InputHdrFrom = Request.GetHeader("From");
  var InputHdrSubject = Request.GetHeader("Subject");

  var notify = true;

  if(NotifyWhenHeadersMatch) {

    notify = false;

    // locate header file
    var objShell = new ActiveXObject("WScript.Shell");
    var sys_db = objShell.RegRead("HKLM\\Software\\Fastraq\\Mailtraq\\DatabasePath");
    var HdrMatchFilePath = sys_db + "\\database\\" + HdrMatchFile;

    // read header file, test headers
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    if(fso.FileExists(HdrMatchFilePath)) {
      var f = fso.GetFile(HdrMatchFilePath);
      var ForReading = 1, line = "";
      var HeaderToTest = "", InputHeaderValue = "";
      var ts = f.OpenAsTextStream(ForReading);
      while(!ts.AtEndOfStream && !notify) {
        line = ts.ReadLine();
        if(/^\[.*\]$/.test(line)) {
           HeaderToTest = line.replace(/\[(.*)\]/, "$1");
           InputHeaderValue = Request.GetHeader(HeaderToTest);
        } else {
          if(InputHeaderValue != "" && line != "") {
            var re = new RegExp(line, "igm");
            notify = re.test(InputHeaderValue);
          }
        } 
      }
      ts.Close();
    }
  }

  if(notify) {
 
    var OutputMsgHdrs = "To: " + OutputMsgAddress + "\r\n" +
                        "Subject: " + OutputMsgSubject + "\r\n" +
                        "From: " + OutputMsgFrom + "\r\n" +
                        "Precedence: bulk" + "\r\n" +
                        "X-POST-MessageClass: 9; Autoresponder" + "\r\n";

    var OutputMsgBody = "Message received:" + "\r\n" +
                        "From: " + InputHdrFrom + "\r\n" +
                        "Subject: " + InputHdrSubject;

    Server.MessageSend("", OutputMsgAddress, OutputMsgHdrs, OutputMsgBody, "", "");

  }

  // Divert Mtq's native autoresponder template response
  Response.Recipients.Set(0, "dev-null");
  Response.SetHeader("X-MTQ-Route", "Dev/null");

%>

Mailtraq's native template response can be expired in a dev-null mailslot or you could use Automated Scripting to fire a blank script (say, dev-null.mtq) - Trigger: Mail Routing, Filter: X-MTQ-Route = dev/null & use the handoff property to drop the message.

Just ask for clarification if there are any glitches or any of this sounds crazy. ;-)

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK


Return to Mailtraq Scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron