There are several ways, but this is a more complex question than it may seem like it is.
You will have to deal with bad email addresses, deciding which information to send, showing delivery times, etc. You also have to be very careful with credit card information -- if you have not taken the proper security measures (by enabling PGP credit card encryption or using CyberCash) you might just mail them their own unencrypted credit card number!
If you still decide to do this, then I will show what I consider to be the best method -- and Caveat Emptor.
Use a GlobalSub
This is the best way, as it is fairly secure. (In case you are one of those people who go light on the documentation 8-(, you will need to read it in this case.)
GlobalSub <<EOF sub form_mail { my($to, $subject, $reply, $body) = @_; my($ok); return '' unless $to; $subject = 'Copy of your order' unless $subject; $reply = '' unless defined $reply; $reply = "Reply-to: $reply\n" if $reply; $ok = 0; SEND: { open(Vend::FORMMAIL,"|$Vend::Cfg->{SendMailProgram} -t") or last SEND; print Vend::FORMMAIL "To: $to\n", $reply, "Subject: $subject\n\n", $body or last SEND; close Vend::FORMMAIL 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"); } return $ok ? 'Copy mailed to user.' : 'EMAIL COPY FAILED.'; } EOF
The above routine can be called on the report.html page with:
[perl arg=sub interpolate=1] form_mail ( q{[value email]}, 'Your order from mycompany.com', 'sales@mycompany.com', <<'EndOfOrder' ) NAME: [value name] ADDRESS: [value address] [value city] [value state] [value zip] [value country] [item-list] [item-quantity] [item-code] [item-description] [item-price] [/item-list] SUBTOTAL: [subtotal] SALESTAX: [salestax] SHIPPING: [shipping] TOTAL: [total-cost] EndOfOrder [/perl]
(With the old parser, you use [perl sub] ... [/perl] with double brackets around some of the inside MiniVend tags.)
Of course you can place any valid tags in the body -- which is that area before the EndOfOrder ``here document'' marker. The usual here document caveats apply -- must be by itself at the beginning of a line, with no trailing whitespace, and watch those carriage returns if you use a Wintel machine.