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

Re: [MacPerl] Mail::Whatever



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 5:13 PM -0800 2/9/98, Josh Gemmell wrote:

} Hi,
}
} 	I been having some troubles trying to decode how to send some mail
}using the
} Mail:: modules. I've been having one of those times when nothing works, no
} matter how hard I try, and everything is just beyond my realm of
}experience. As
} beautiful as Macs are, I find that trying to program on them can cause actual
} physical pain from the mental anguish. For example, how the heck do you call
} one program from another one? AppleEvents? Brrr! Gimme back my command line.
} 	Anyways, that's not your problem.
} 	I want to create my own mailer, because every other mailer creates
}ugly mail.
} So, what better way to do it than with Perl? In fact, I created a beautified
} mail mailer for our UNIX server and it works great. But - how to do it on a
} Mac?... Java? I've spent DAYS trying to find some kind of info on CGI
} programming in Java on a Mac. MondoMail called by MacPerl? I don't know how.
} Even after reading Chris Nandor's great article in TPJ, I still don't
}know how
} (I tried, but his examples are so different from what I need to do). And
}so I'm
} going back to what I originally tried (and failed) to do: use pure MacPerl.
} 	Here's what I've managed from the docs:
}
} #!perl
}
} use Mail::Header;
} use Mail::Internet;
}
} $ENV{USER}       = 'webmaster';
} $ENV{MAILDOMAIN} = 'ola.bc.ca';
} $ENV{NAME}       = 'webmaster';
} $ENV{SMTPHOSTS}  = 'paros.ola.bc.ca';
} @myText          = ("This is a test.","Only a test.");
} $myFrom          = 'joshg@ola.bc.ca';
} $myTo            = 'joshg@ola.bc.ca';
} $mySubject       = 'ola test 1';
}
} $head = new Mail::Header;
} $head->add('From',$myFrom);
} $head->add('Reply-To',$myFrom);
} $head->add('To',$myTo);
} $head->add('Subject',$mySubject);
}
} $int= new Mail::Internet(Header, $head, Body, @myText);
} $int->print();
}
} exit(0);
}
} AND here's the output:
}
} # Can't use string ("Header") as a symbol ref while "strict refs" in use.
} File 'Boba Fett:Applications:MacPerl f:lib:Mail:Internet.pm'; Line 46
}
} 	Digging deep into this OOP code is a major headache. I have no idea
}what line
} 46 does, let alone why it's barfing about ("Header") as a symbol
}reference. ANY
} help would be very much appreciated.

It's just as the built-in pod docs say.  Body has to be a reference to an
array, not an array.  So you should write:

$int= new Mail::Internet(Header => $head, Body => \@myText);

The next problem is that the lines in @myText all have to be newline
terminated:

@myText          = ("This is a test.\n","Only a test.\n");

The following works for me.  (Note  that I have all the relevant
environment variables defined in MacPerl's environment editor, so I don't
include them here):

#!perl

use Mail::Header;
use Mail::Internet;

$myFrom          = 'schinder@pobox.com';
$myTo            = 'schinder@leprss.gsfc.nasa.gov';
$mySubject       = 'ola test 1';
@myText          = ("This is a test.\n","Only a test.\n");

$head = new Mail::Header;
$head->add('From',$myFrom);
$head->add('Reply-To',$myFrom);
$head->add('To',$myTo);
$head->add('Subject',$mySubject);

$int= new Mail::Internet(Header => $head, Body => \@myText);
$int->print;
__END__

If you now want to send this (please don't without changing $myTo and $myFrom):

$int->smtpsend;


}
} -josh
} -----------------------------------------------------------------
}                        Open Learning Agency
} 4355 Mathissi Place, Burnaby, B.C. Canada, V5G 4S8 (604) 431-3000
}
}
} ***** Want to unsubscribe from this list?
} ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch



- -----
Paul J. Schinder
schinder@pobox.com


-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBNN+5AlZaVc52j0XhEQIL6ACgoHgbI515BBTvAUiyhBYAaJQY/8oAn2mk
1BtSXKaV4BXZT5IfPHQMeiyC
=jIZG
-----END PGP SIGNATURE-----


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch