Re: Shell scripts and the SMTP protocol
From: John W. Krahn (krahnj_at_acm.org)
Date: 07/13/04
- Next message: bsh_at_iname.com: "Re: Can I echo a header to the top of my console ?"
- Previous message: bsh_at_iname.com: "Re: About the "return" build-in function in ksh"
- In reply to: Paul Smith: "Re: Shell scripts and the SMTP protocol"
- Next in thread: John DuBois: "Re: Shell scripts and the SMTP protocol"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 13 Jul 2004 01:14:06 GMT
Paul Smith wrote:
>
> >> I am wanting to write a script to send an e-mail through the SMTP
> server
> >> of my ISP. What is the proper command to do this?
> >
> > #!/usr/bin/perl
> >
> > use Mail::Mailer;
> >
> > my $mailer = new Mail::Mailer smtp => Server => 'smtp.hotpop.com';
> >
> > $mailer->open( {
> > To => 'My Friend <myfriend@example.com>',
> > From => 'Paul Smith <phhs80@hotpop.com>',
> > Subject => 'This is a test',
> > } );
> >
> > print $mailer <<BODY;
> > Hi,
> >
> > This is a test.
> >
> > Paul
> > BODY
> >
> > $mailer->close;
> >
> > __END__
>
> Meanwhile, I have replaced the smtp server with a different one and
> John Krahn's script worked nicely. Unfortunately, I get the e-mails
> (sent by John's script) showing a time as they were sent one hour
> before. Is there some way of repairing it?
The program as written just uses the default localtime but you could add
a date header and put in whatever date you want.
my @wds = qw( Sun Mon Tue Wed Thu Fri Sat );
my @mns = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my @lt = gmtime; # GMT - now UTC - AKA Zulu time
$mailer->open( {
To => 'My Friend <myfriend@example.com>',
From => 'Paul Smith <phhs80@hotpop.com>',
Subject => 'This is a test',
# Date => 'Tue, 13 Jul 2004 00:57:33 GMT',
Date => sprintf( '%s, %2d %s %04d %02d:%02d:%02d GMT',
$wds[ $lt[ 6 ] ], $lt[ 3 ], $mns[ $lt[ 4 ] ], @lt[ 5, 2, 1, 0 ] )
} );
John
-- use Perl; program fulfillment
- Next message: bsh_at_iname.com: "Re: Can I echo a header to the top of my console ?"
- Previous message: bsh_at_iname.com: "Re: About the "return" build-in function in ksh"
- In reply to: Paul Smith: "Re: Shell scripts and the SMTP protocol"
- Next in thread: John DuBois: "Re: Shell scripts and the SMTP protocol"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|