RE: Large amounts of email

From: John Madden (no email)
Date: Thu Nov 01 2001 - 08:51:03 EST


>>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
-
To unsubscribe, send mail to  with content
(not subject): unsubscribe postfix-users







Hosted Email Solutions

Invaluement Anti-Spam DNSBLs



Powered By FreeBSD   Powered By FreeBSD