email piped to script... BCC?

Posted on 2006-05-10
Last Modified: 2013-12-25

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?
Question by:sharpmail
    LVL 48

    Expert Comment

    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.

    Author Comment

    I have managed to sort the problem out, posfix an dpossibly other mail programs adds

    received from []
    for <> 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

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at (http://www.experts-ex…
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now