Missing some inbound email headers

nlil
Kilo Explorer

Hi Folks,

 

We are working on inbound email processing and we need to parse some information from the inbound email headers. I have discovered that some of the email headers that I need are not present. Specifically, I am looking for the "Received:" headers. Typically, there will be one of these headers for each server that the message passed though on it's way to it's destination.

 

Received: from uni00mi.unity.ncsu.edu (uni00mi.unity.ncsu.edu. [152.1.2.224])

              by mx.google.com with ESMTP id w138si1625903ykb.37.2014.10.28.08.05.24

              for <servicenow-postmaster@ncsu.edu>;

              Tue, 28 Oct 2014 08:05:24 -0700 (PDT)

Received: from psmtp.com (na3sys009amx244.postini.com [74.125.149.8])

  by uni00mi.unity.ncsu.edu (8.14.4/8.14.4/Nv6.2010.0805) with ESMTP id s9SF5M3e022661

  for <servicenow-postmaster@ncsu.edu>; Tue, 28 Oct 2014 11:05:23 -0400 (EDT)

Received: from na3sys009aog101.obsmtp.com ([74.125.149.67]) (using TLSv1) by na3sys009amx244.postini.com ([74.125.148.10]) with SMTP;

  Tue, 28 Oct 2014 15:05:23 GMT

Received: from uni01mo.unity.ncsu.edu ([152.1.225.228]) (using TLSv1) by na3sys009aob101.postini.com ([74.125.148.12]) with SMTP

  ID DSNKVE+wstUsJ6w8aUsHJljxsRRfMfcCvRrL@postini.com; Tue, 28 Oct 2014 08:05:23 PDT

Received: from ars00srv.unity.ncsu.edu (ars00srv.unity.ncsu.edu [152.1.227.134])

  by uni01mo.unity.ncsu.edu (8.14.4/8.14.4/Nv6.2010.0805) with ESMTP id s9SF5LeE013964

  for <servicenow-postmaster@ncsu.edu>; Tue, 28 Oct 2014 11:05:21 -0400 (EDT)

Received: from uni01mi.unity.ncsu.edu (uni01mi.unity.ncsu.edu [152.1.225.224])

  by ars00srv.unity.ncsu.edu (8.14.4+Sun/8.14.4/Nv6.2010.0805) with ESMTP id s9SF5L8u015289

  for <test@help.ncsu.edu>; Tue, 28 Oct 2014 11:05:21 -0400 (EDT)

Received: from psmtp.com (na3sys009amx217.postini.com [74.125.149.57])

  by uni01mi.unity.ncsu.edu (8.14.4/8.14.4/Nv6.2010.0805) with ESMTP id s9SF5KFQ011929

  for <test@help.ncsu.edu>; Tue, 28 Oct 2014 11:05:21 -0400 (EDT)


Unfortunately, the header I need (specifically, the one in bold) is not included in the headers by the time my script gets them.


Is there any way to control which headers from the original inbound message make it into the headers that are accessible from within a script? I am using the Postmaster app to do this processing.


Thanks for any insights.

Larry

9 REPLIES 9

poyntzj
Kilo Sage

I did not find an answer when I was looking to grab a Reply-To address (for a email ebonding where there is a unique email address for every ticket in the remote system)


I ended up with this code (assistance from David Ainsworth @ servicenow)



var re = /Reply-To:\s*[^<]*<?([^>]*)/;


      var m = re.exec(email.headers);


      if(!m) return false;


      if (m.length > 1) return m[1];


      if (m.length == 1) return m[0];



could adapt it to read the received header value and loop through the returned array


Hi Julian,



Thanks for the reply. I ultimately hope to do something very similar to what you suggest but my immediate problem is that the headers that I want to search against aren't present. I have dumped the "email.headers" to a debug log and they just aren't there. The headers I included in the original message were copied from a similar email from another system.



So I'm trying to discover if there is a way to get the "Received: " headers included in the email.headers.



Thanks.


Larry


if you go into the sys_email table and look at the headers of the received message, are the Received fields there?


Hi Brent,



Nope, there is only one "Received: " header... the last one. All of the others that should be there are missing.



Thanks.


Larry