A.3. form_mail.cfg

GlobalSub <<EndOfSub
sub form_mail {
    my($to, $subject, $reply, $body) = @_;
    my($ok);

    $subject = '<no subject>' unless defined $subject && $subject;

    $reply = '' unless defined $reply;
    $reply = "Reply-to: $reply\n" if $reply;

    $ok = 0;
    SEND: {
        open(Vend::MAIL,"|$Vend::Cfg->{'SendMailProgram'} -t") or last SEND;
        print Vend::MAIL
            "To: $to\n",
            $reply,
            "Subject: $subject\n",
            "Errors-To: $Vend::Cfg->{MailOrderTo}\n\n",
            $body
            or last SEND;
        close Vend::MAIL or last SEND;
        $ok = ($? == 0);
    }

    if (!$ok) {
        logError("Unable to send mail using $Vend::Cfg->{'SendMailProgram'}\n" .
            "To '$to'\n" .
            "With subject '$subject'\n" .
            "With reply-to '$reply'\n" .
            "And body:\n$body");
    }
    $ok;
}
EndOfSub