This works for me:

        use strict;
        use Mail::Sendmail;
        use MIME::QuotedPrint;
        use MIME::Base64;

        my %mail = {};

        open(LOG, ">>logfile") or die "Can't open logfile! - ($!)";
        &send_email('[EMAIL PROTECTED]');

        }

        sub send_email {

            my $address = $_[0];

            &compose_email($address);
            
            unless (sendmail %mail) { 
                print LOG "$Mail::Sendmail::error \n";
                print LOG "\n$Mail::Sendmail::log\n";
                return 0;
            }

            print LOG "\n$Mail::Sendmail::log\n";
            
        }

        sub compose_email {
                
            my $to_address = $_[0];
            my $from_address = '[EMAIL PROTECTED]';

            %mail = ( Smtp    => 'smtp-server-name',
                      To      => "$to_address",
                      From    => "$from_address",
                      Subject => 'Email to Whoever',
                     );

            $mail{Date} = Mail::Sendmail::time_to_date( time() );
            $mail{'content-type'} = "text/html";
            $mail{message} = qq{<HTML><BODY><P> 
                Blah, blah, blah... <br><br> 
                </P></BODY></HTML>};

        }
            
This sends in HTML.  If you prefer plain text or rich text you would change
the $mail{'content-type'} to "text/plain" or "text/enriched" and remove the
HTML tags from $mail{message}.  I have other examples that do
multipart/mixed types with encoded attachments if you're interested.  Hope
it helps.

Carl J. Bauman
Senior Business Analyst
Information Technology
Ultramar Diamond Shamrock Corporation
(210) 592-4018
[EMAIL PROTECTED]


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to