• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

email piped to script... BCC?

Hi,

I have email piped to a perl script which grabs who the email was sent to and from etc

I need to know who the email was intended for (To) but when an email is sent BCC the To field is not the address the email was delivered to. How can I get the address the email was delivered to?
0
sharpmail
Asked:
sharpmail
1 Solution
 
TintinCommented:
Short answer; you can't.

Longer answer; you can only obtain this information by having access to the mail server the originating mail was sent from.
0
 
sharpmailAuthor Commented:
I have managed to sort the problem out, posfix an dpossibly other mail programs adds

received from [xxx.xxx.xxx.xxx]
for <email@address.com> on dd mmm timezone yyyy hh:mm:ss

looping over the lines i simply lokked for a string match of  $line=~ m/for </i; when I had this line split it by the < and split the right eliment by the > leaving the left eliment the email address

when to, from, subject and for lines were found stopped the loop.


@email = <STDIN>;   # read the email from STDIN

foreach $line (@email){ # loop over the email to find the lines we want
if($line=~m/^From: /){$from = "$line";}
if($line=~m/^To: /){$to = "$line";}
if($line=~m/^Subject: /){$subject = "$line";}
if($line=~m/for </ && $forwho eq ""){$forwho = "$line";}      # if BCC then this is the real delivered to?
last if($from ne "" && $to ne "" && $subject ne "" && $forwho ne ""); # end the loop if we have what we wanted
}
@foraddy= split(/</ ,$forwho);
$forwho = $foraddy[1];    # cut garbage from the leff
@foraddy= split(/>/ ,$forwho);
$forwho = $foraddy[0];   # cut garbage off the right and leave the address
0
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now