Anthony,

I'm not much less new than you, but I went through this recently and
used Sendmail for UNIX server and Mail::Sender for SMPT mail on a
Windows NT server.

The documentation for Mail::Sender is at:

http://search.cpan.org/doc/JENDA/Mail-Sender-0.7.10/Sender.pm.html

and sending mail took a bit of code like this:

ref ($sender = new Mail::Sender({from => '[EMAIL PROTECTED]', smtp
=> 'company.com'})) or die "$Mail::Sender::Error\n";

(ref ($sender->MailMsg(
        {to =>$Email, 
        cc => '[EMAIL PROTECTED]',
        subject => 'Subject Text Here',
        msg => $Message
  }))
  and print "Mail sent OK."
 )
 or die "$Mail::Sender::Error\n";

# (where $Email was pre-set from a web-form submission and $message was
a pre-set message in the variable)

***********

Using Sendmail on the UNIX server, the code came out like this:

$emailProgram   = "| /usr/sbin/sendmail -oi -t"; # your path might be
different
$emailRecipient = $Email;  # as filled out from a web-form in this case
$emailAdmin = "addressee\@company.com";    
$emailSender = "addressee\@company.com";
$emailSubject = "Subject Text Here";
$message  = "Full Text of Email message here";

# Then sending the email:

$errmsg = &SendMessage (
    'to'       => $emailRecipient,
    'cc'           => $emailAdmin,
    'from'     => $emailSender,
    'subject'  => $emailSubject,
    'message'  => $message,
);

#   then, a routine to handle interaction with sendmail:

sub SendMessage
{
    my (%args) = @_;

    if (not $args{from})    { return "No 'from' header."; }
    if (not $args{to})      { return "Please go back and enter your
email address"; }
    if (not $args{subject}) { return "No 'subject' header."; }

    if (open SENDMAIL, $emailProgram)
    {
        print SENDMAIL "From: $args{from}\n";

        if ($args{'reply-to'})
        { print SENDMAIL "Reply-to: ", $args{'reply-to'}, "\n"; }

        print SENDMAIL "To: $args{to}\n";

        if ($args{cc})
        { print SENDMAIL "Cc: $args{cc}\n"; }

        print SENDMAIL "Subject: $args{subject}\n";
        print SENDMAIL "\n";
        print SENDMAIL $args{message};
        print SENDMAIL "\n";

        close SENDMAIL;
        return "sent";
    }
    else { return "Can't launch sendmail."; }
}

Hope this helps!

Rohesia Hamilton Metcalfe

--- "Jones, Anthony T" <[EMAIL PROTECTED]> wrote:
>       Hello all,
>       I just started Perl this week.  I am looking to do a simple module
> to send mail over Unix and Windows, with a little bit of error
> checking if
> possible.  Can anyone point me in the right direction with a link or
> module?
> I've begun looking through cpan a bit, but most of the modules I see
> are
> large and complex with classes.
>       Thanks.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


=====
Rohesia Hamilton Metcalfe

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to