CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
READ/OPEN TEXT -> SEND MAIL

 



xter74
Novice

Oct 15, 2002, 7:34 PM

Post #1 of 4 (389 views)
READ/OPEN TEXT -> SEND MAIL Can't Post

 
Hi gurus,

I'll need some help here. I had a subroutine which perform the open/read function and send it to a smtp server.
I had tried several methods from the forum and books but I still can't get it to work. Unsure

Thanks for the advise, the following is the codes that I have.......

*********************************************************
sub capture {

use strict;

#my %hash = ();
#open MAIL, "E:/Webs/blt.sgp.hp.com/share/cgi-bin/mail.log" or die $!;
#read MAIL, $hash{key}, -s MAIL;

open MAILLOG, "E:/Webs/blt.sgp.hp.com/share/cgi-bin/mail.log" or die $!;
read MAILLOG;

#$inline = $_;
#$inline = $hash;
#$mail_msg .= $inline;
$mail_msg = <MAILLOG>;

&send_msg;

sub send_msg {

open LOG, '>> E:/Webs/blt.sgp.hp.com/share/cgi-bin/smtp.log' or die "Cannot open file";
print LOG "\n===============================================\n";
print LOG scalar(localtime), " Started log.\n";
use IO::Socket;

$SMTP_SERVER="ctss21.sgp.hp.com";

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$SMTP_SERVER",
PeerPort => "smtp(25)",
) || die "cannot connect to SMTP port on $SMTP_SERVER\n";

$remote->autoflush(1);

$inline = <$remote>;
if( $inline !~ /^220/ ) {
print LOG "Didn't get 220 response: $inline";
return;
}
print LOG $inline;

#print "<br>sending: ", "HELO $SMTP_SERVER\n";
print $remote "HELO $SMTP_SERVER\n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at HELO: $inline";
return;
}
print LOG "$inline";

#print "<br>sending: ", "MAIL From: $src_addr\n";
print $remote "MAIL From: ap-blt_support\@hp.com\n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at MAIL: $inline";
return;
}
print LOG "$inline";

print "<br>sending: ", "RCPT To: $dst_addr\n <BR>";
# print $remote "RCPT To: $dst_addr\n";
print $remote "RCPT To: arsystem\@uspsgn01.sgp.hp.com \n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at RCPT: $inline";
return;
}
print LOG "$inline";

#print "<br>sending: ", "DATA\n";
print $remote "DATA\n";
$inline = <$remote>;
if( $inline !~ /^354/ ) {
print LOG "Didn't get 354 response at DATA: $inline";
return;
}
print LOG "$inline";
print "\n============>$inline";

print $remote $mail_msg;
print "\n\n=========>>>>$mail_msg";
print $remote "\n.\n";

# Accepted for delivery message
$inline = <$remote>;
print LOG $inline;

print $remote "QUIT\n";
$inline = <$remote>;
print LOG $inline;
}
close MAILLOG;
}


Paul
Enthusiast

Oct 16, 2002, 2:45 AM

Post #2 of 4 (380 views)
Re: [xter74] READ/OPEN TEXT -> SEND MAIL [In reply to] Can't Post

Use Net::SMTP Wink


xter74
Novice

Oct 16, 2002, 8:10 PM

Post #3 of 4 (375 views)
Re: [RedRum] READ/OPEN TEXT -> SEND MAIL [In reply to] Can't Post

Hi Redrum, thanks for the advise....as I am a newbie, I'm not sure how can I incorporated it into the existing script which is pass to me by a counterpart?Crazy

Do you have any idea how do I modify the existing script so that content of a txt file can be captured and send it to the smtp server (ctss11.sgp.hp.com)?

Thanks a lot for the help and greatly appreciate that.... Smile


thodi
stranger

Oct 18, 2002, 3:26 AM

Post #4 of 4 (367 views)
Re: [xter74] READ/OPEN TEXT -> SEND MAIL [In reply to] Can't Post

All the documentation you need is available on the web. http://www.perldoc.com/perl5.8.0/lib/Net/SMTP.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives