OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: John Madden (jmaddenivy.tec.in.us)
Date: Thu Nov 01 2001 - 07:51:03 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    >>Yes, via SMTP. That's faster. Use Perl's Net::SMTP for example.
    >
    >
    > The problem I have found with Net::SMTP is that it wants the headers
    > declared in a separate field than the body. In the past I was able to
    > pipe the entire email to sendmail. Is anyone aware of existing code or
    > a module to 'extract' the headers (To:, From:, Subject:, Cc:, and Bcc:
    > fields) from a file and convert it into something that Net::SMTP can
    > use?

    Well the problem is that the sendmail client isn't at all a true SMTP
    client. That single binary handles local delivery, remote connections,
    etc. Run with the right args, it's even an smtp daemon...

    $smtp = Net::SMTP->new("localhost");
    $smtp->mail("from address");
    $smtp->to("to address");
    $smtp->data();
    $smtp->datasend("$entire_email_with_headers");
    $smtp->dataend();
    $smtp->quit();

    And if you mean you'll have trouble getting the From and To addresses, just
    parse them out:

    open (FILE, "/path/to/email_file");
    my ($from, $to);
    while(<FILE>)
    {
      $from = $1 if(/^From: (.*)/);
      $to = $1 if (/^To: (.*)/);
    }
    close FILE;

    ...Or something similar.

    John

    -- 
    John Madden
    UNIX Systems Engineer
    Ivy Tech State College
    jmaddenivy.tec.in.us
    

    - To unsubscribe, send mail to majordomopostfix.org with content (not subject): unsubscribe postfix-users