#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $lineBufferStatus = 0; my @rcptBuffer = (); my @linesBuffer = (); my $msgUpdateCnt = 0; while () { if ( $_ =~ /^DATA(?:\n|\r\n)$/ ) { print "In second If statement DATA if statement\n"; @linesBuffer = (); $lineBufferStatus = 0; } elsif ( $_ =~ /^\.(?:\n|\r\n)$/ ) { if ( int(@linesBuffer) > 0 ) { while( int(@linesBuffer) > 0 ) { print shift(@linesBuffer); } print "\r\n.\r\nQUIT\r\n"; $msgUpdateCnt++; } $lineBufferStatus = 1; } elsif ( $lineBufferStatus == 0 ) { push( @linesBuffer, $_ ); } } if ( int(@linesBuffer) > 0 ) { my $perMsgRcptBufCnt = 0; while( int(@linesBuffer) > 0 ) { print shift(@linesBuffer); } print "\r\n.\r\nQUIT\r\n"; $msgUpdateCnt++; } if ( $msgUpdateCnt == 1 ) { print "---------------------EQUALS 1--------------------\n"; } elsif ( $msgUpdateCnt > 1 ) { print "---------------------EQUALS 2--------------------\n"; } __DATA__ EHLO testdomain.com MAIL FROM: SIZE=1016 BODY=7BIT RCPT TO: RCPT TO: DATA Received: from 1.1.1.1(helo=mvastnlufgt.mgrjofpxydauvu.info) by with esmtpa (Exim 4.69) (envelope-from ) id 1MM6HB-1114fm-3T for testuser01@testdomain.com; Sun, 9 Jan 2011 23:07:59 +0100 From: "outsideuser01" To: Subject: Re: good evening Date: Sun, 9 Jan 2011 23:07:59 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_ppstll_21_19_24" X-Priority: 3 X-Mailer: choakmps.33 Message-ID: <5C74A867.4001970@aclighting.com> ------=_ppstll_21_19_24 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable H i website: http://canadianph.tz= hzvebp.ajwcd.ru - CanadianPharmacy ------=_ppstll_21_19_24 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable H i
website: http://canadianph.tzhzvebp.ajwcd.ru - CanadianPharmacy = ------=_ppstll_21_19_24-- . RSET MAIL FROM: SIZE=1016 BODY=7BIT RCPT TO: RCPT TO: RCPT TO: DATA Received: from mdmcfntioehaoqtcmjdmjmcm (192.168.1.33) by wonderware.com (80.149.49.194) with Microsoft SMTP Server id 8.0.685.24; Sun, 9 Jan 2011 23:08:07 +0100 Message-ID: <4D2A2627.204070@pacunion.com> Date: Sun, 9 Jan 2011 23:08:07 +0100 From: "Megan" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100921 Thunderbird/3.1.4 MIME-Version: 1.0 To: Subject: good morning Content-Type: multipart/alternative; boundary="------------02070800106050608090806" X-Priority: 3 X-Mailer: choakmps.33 Message-ID: <5C74A867.4001970@aclighting.com> ------=_ppstll_21_19_24 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi website: http://canadianp= kerur.ru - CanadianPharmacy ------=_ppstll_21_19_24 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable H i
website: http://canadianp.kerur.ru - GermanPharmacy = ------=_ppstll_21_19_24-- . RSET MAIL FROM: SIZE=9916 BODY=7BIT RCPT TO: RCPT TO: DATA Received: from testdomains (172.12.223.44) by wonderware.com (32.34.49.194) with Microsoft 23:08:07 +0100 Message-ID: <4D2A2627.204070@pacunion.com> Date: Sat, 8 Jan 2011 17:18:27 +0100 From: "Megan" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100921 Thunderbird/3.1.4 MIME-Version: 1.0 To: Subject: morning Content-Type: multipart/alternative; boundary="------------02070800106050608090806" X-Priority: 3 X-Mailer: choakmps.33 Message-ID: <5C74A867.4001970@aclighting.com> ------=_ppstll_21_19_24 Content-Type: text/plain; . RSET #### --------THIS IS THE CURRENT OUTPUT-------- Received: from testdomains (172.12.223.44) by wonderware.com (32.34.49.194) with Microsoft 23:08:07 +0100 Message-ID: <4D2A2627.204070@pacunion.com> Date: Sat, 8 Jan 2011 17:18:27 +0100 From: "Megan" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100921 Thunderbird/3.1.4 MIME-Version: 1.0 To: --------THIS IS THE DESIRED OUTPUT ( I have captured both RCPT TO: lines and appended them after the Original To:)-------- Received: from testdomains (172.12.223.44) by wonderware.com (32.34.49.194) with Microsoft 23:08:07 +0100 Message-ID: <4D2A2627.204070@pacunion.com> Date: Sat, 8 Jan 2011 17:18:27 +0100 From: "Megan" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100921 Thunderbird/3.1.4 MIME-Version: 1.0 To: To: To: