[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] sendmail.pl



>#!perl
>
>use strict;
>use Net::SMTP;
>use Mac::InternetConfig;
>
>my($smtp, $email, @emails, $subject, $message);
>
>$smtp    = Net::SMTP->new();
>$email   = $InternetConfig{kICEmail()};  # get sender from IC
>@emails  = 'some_user@some.domain';      # recipient goes here
>$subject = "Subject: MacPerl test message\n\n";
>$message = <<EOM;
>
>Place test message here
>
>EOM
>
>$smtp->mail($email)       or warn('failure');
>$smtp->to(@emails)        or warn('failure');
>$smtp->data()             or warn('failure');
>$smtp->datasend($subject) or warn('failure');
>$smtp->datasend($message) or warn('failure');
>$smtp->datasend()         or warn('failure');
>$smtp->quit()             or warn('failure');

Sorry, but I couldn't resist rewriting it using Mail::Sendmail. It's
shorter and will also give you clear error messages if needed, do Mime
quoted-printable encoding for you, etc...

#!perl

use strict;
use Mail::Sendmail;
use Mac::InternetConfig;

my %mail = (
    From => $InternetConfig{kICEmail()},  # get sender from IC
    To   => 'some_user@some.domain',      # recipients go here
    Subject => "MacPerl test message",
);

$mail{Message} = <<EOM;

Place test message here

EOM

sendmail(%mail) or warn $Mail::Sendmail::error;


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org