kapot
07-15-2004, 03:19 PM
I tried to send email using perl, but it always sent without subject.
Anyone know how to fix this ?
#!/usr/bin/perl
use Net::SMTP;
$from = "support\@mycompany.com";
$subject = "A subject";
open(TXT, "address.txt") || die "Cant open address.txt $!\n";
@Email = <TXT>;
close(TXT);
open F, "email.txt" or die "Error reading email.txt: $!";
{local $/; $body = <F>;}
close F;
foreach $email (@Email)
{
$smtp = Net::SMTP->new('localhost');
$smtp->mail("$from");
$smtp->to("$email");
$smtp->data();
$smtp->datasend('To: '.$email."\n");
$smtp->datasend('From: '.$from."\n");
$smtp->datasend('Subject: '.$subject."\n");
$smtp->datasend($body."\n");
$smtp->dataend();
$smtp->quit;
}
Anyone know how to fix this ?
#!/usr/bin/perl
use Net::SMTP;
$from = "support\@mycompany.com";
$subject = "A subject";
open(TXT, "address.txt") || die "Cant open address.txt $!\n";
@Email = <TXT>;
close(TXT);
open F, "email.txt" or die "Error reading email.txt: $!";
{local $/; $body = <F>;}
close F;
foreach $email (@Email)
{
$smtp = Net::SMTP->new('localhost');
$smtp->mail("$from");
$smtp->to("$email");
$smtp->data();
$smtp->datasend('To: '.$email."\n");
$smtp->datasend('From: '.$from."\n");
$smtp->datasend('Subject: '.$subject."\n");
$smtp->datasend($body."\n");
$smtp->dataend();
$smtp->quit;
}
