.forward file contents

Include the quotes. Replace filepath with the right one for your server, and the perl script name with the script name you're using.

 "| /Users/davidloo/email_create.pl"

== email_create.pl perl script contents ==

Put the script in the folder specified in the .forward file.
  #!/usr/bin/perl
  #
  use strict;
  use SOAP::Lite;
  use XML::Writer;
  use XML::Writer::String;
  
  my $SNC_HOST = "https://instance_name.service-now.com";
  
  email_create();
  
  sub email_create {
    my $soap = SOAP::Lite->proxy("$SNC_HOST/ecc_queue.do?SOAP");
    my $method = SOAP::Data->name('insert')->attr({xmlns =>   'http://www.service-now.com/'});  
  
    # set ECC Queue Agent so that the InboundEmail processor will be
    # executed
    my @params = ( SOAP::Data->name(agent => 'InboundEmail') );
    push(@params, SOAP::Data->name(queue => 'input') );
    push(@params, SOAP::Data->name(name => 'Inbound Email Processing') );
  
    # read stdin line by line into the email variable
    my $email;
    my $lcount = 0;
    while (<STDIN>) {
      if ($lcount == 0) {
        push(@params, SOAP::Data->name(source => $_) );
      } else {
        $email .= $_;
      }
      $lcount++;
    }
  
    # set the entire content of the email into the payload field
    push(@params, SOAP::Data->name(payload => $email) );
  
    # invoke the SOAP request
    my $result = $soap->call($method => @params);
  
    # capture the errors that occur and echo to stdout
    if ($result->fault) {
      print "faultcode=" . $result->fault->{'faultcode'} . "\n";
      print "faultstring=" . $result->fault->{'faultstring'} . "\n";
      print "detail=" . $result->fault->{'detail'} . "\n";
    }
  
    # capture the response and echo it to stdout
    if ($result->body && $result->body->{'insertResponse'}) {
      my %keyHash = %{ $result->body->{'insertResponse'} };
      foreach my $k (keys %keyHash) {
          print "name=$k   value=$keyHash{$k}\n"; 
      }
    }
  }

  # add the following subroutine if basic authentication for SOAP is enabled
  # enter the username, password that you will use
  sub SOAP::Transport::HTTP::Client::get_basic_credentials {
   return 'username' => 'password';
  }