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

Re: [MacPerl] sendmail.pl



>>Can someone send me a copy of sendmail.pl ?  I am not using a
>>unix server, I am using a Mac with First Class running macperl.
>>(yes, finally got it working!).
>
>Never heard of sendmail.pl.  Try usin MailTools or Net::SMTP by itself.

What Chris said.

Short and very sweet example using Net::SMTP and Mac::InternetConfig (The 
latter just to get the sender's email address).  Can't recall if this is 
on the MPPE CD-ROM.  I don't *think* I wrote this, although a greatly 
modified version now resides on my hard disk.

Mailtools makes some Unixy assumptions which Paul Schinder has taken care 
of most of in the Mac port.  If you use Mailtools be sure to read the 
"README.Mailtools.mac" file (duh!).

#!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');

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