mboudreau has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I'm developing an application on OS X (10.5.7) using Apache (2.2.11), mod_perl (2.0.2) and Mason. I'm using MIME::Entity to create an email, like this (error checking omitted for clarity):

use MIME::Entity; my $entity = MIME::Entity->build ( To => $to, From => $from, Cc => $cc, Subject => $subject, Data => "$body\n" ); open (MAIL, "|/usr/bin/mail"); $entity->print(\*MAIL); close(MAIL);

The problem is that nothing seems to happen. I've used similar code on a Solaris system, where I invoked mail with the "-t" option. On OS X the "-t" option gives me a "broken pipe" error message on the close command. Without that option, no error messages appear, but no mail appears to be sent.

I have looked at the manpage for the OS X mail command and didn't find any help, but it's possible I missed something.

Has anyone been down this road before? Can you point me in the right direction?

Replies are listed 'Best First'.
Re: Sending a MIME::Entity email on OS X
by Anonymous Monk on May 20, 2009 at 03:38 UTC

      Adding

      MIME::Tools->debugging(1); MIME::Tools->quiet(0);
      didn't have any effect: no error messages about the Mime tools.

      However, changing

      open(MAIL, "|/usr/bin/mail");
      to
      open(MAIL, "|/usr/sbin/sendmail -t")
      results in the message being sent.