Re: Shell scripts and the SMTP protocol

From: John W. Krahn (krahnj_at_acm.org)
Date: 07/13/04


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


Relevant Pages

  • Re: Migrating to a new server
    ... "Paul Smith" wrote in message ... my only fear is that since the old server is very buggy and full of problems will stop during the process and everything gets corrupted!!! ... You could just add the new server to the existing domain, DCPromo it, transfer the FMSO roles to it and demote the old DC. ... a new domain as well with new usernames etc but will be using same data so I will need to connect both servers together to transfer data ...
    (microsoft.public.exchange.admin)
  • Re: Permissions problem after upgrade
    ... Mark L. Ferguson MS-MVP ... "Paul Smith" wrote in message ... I just upgraded my 2000 server with an additional 1gb RAM. ... respective folder but still they cannot save, ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Shell scripts and the SMTP protocol
    ... phhs80@hotpop.com (Paul Smith) writes: ... I have replaced the smtp server with a different one and ... Joe ... We can't all be heroes because someone has to sit on the curb and ...
    (comp.unix.shell)
  • Re: Ntpdate fails to start
    ... Paul Smith wrote: ... Does your server as client? ... At booting, ntpdate fails to start, and also the following command fails: ...
    (Fedora)
  • Re: Outlook Express error when sending email
    ... >> with McAfee Antivirus and Firewall disabled. ... >> Looking on MS's Knowledge Base, the error means "0x800CCC0B BUSY Server ... >> The SMTP server was definitely correct - it was the same ISP and same ... > make a clean installation. ...
    (uk.comp.misc)