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

Hi, Can anyone please help me figure out how to pass additional arguments to sendmail in Email::Send. What I'm doing is:
my $sender = Email::Send->new({mailer => 'Sendmail'}); $sender->send($email_raw, '--additional_argument');
Manual says "Any arguments passed to send will be passed to sendmail." But it doesn't seem to be working. I tried my arguments in command line and it works fine. Thanks

Replies are listed 'Best First'.
Re: Email::Send::Sendmail and argument passing
by ikegami (Patriarch) on May 29, 2009 at 23:41 UTC
      It shouldn't matter since Email::Send::Sendmail is run from Email::Send when mailer is 'Sendmail' .. I guess. Or am I missing something?
        Yes, anything showing extra parameters from one send gets passed to the other, or that the other is even called.
Re: Email::Send::Sendmail and argument passing
by Anonymous Monk on May 30, 2009 at 01:56 UTC
    Email::Send also shows
    my $result = $sender->send($message, @modifier_args);
    Maybe you want Debug => 1 in there somewhere.
      this is how present Sendmail send looks like:
      sub send { my ($class, $message, @args) = @_; my $mailer = $class->_find_sendmail; return failure "Couldn't find 'sendmail' executable in your PATH" ." and \$".__PACKAGE__."::SENDMAIL is not set" unless $mailer; return failure "Found $mailer but cannot execute it" unless -x $mailer; local $SIG{'CHLD'} = 'DEFAULT'; my $pipe = gensym; ### print "| $mailer -t -oi @args"; open $pipe, "| $mailer -t -oi @args" or return failure "Error executing $mailer: $!"; print $pipe $message->as_string or return failure "Error printing via pipe to $mailer: $!"; close $pipe or return failure "error when closing pipe to $mailer: $!"; return success; }
      The added debug print line always returns string without any @args no matter how I passed them.