package Cookbook::EmailUploads; use Apache::Constants qw(OK SERVER_ERROR); use Apache::Request; use Cookbook::Mail qw(send_mail); use strict; sub handler { my $r = Apache::Request->new(shift, DISABLE_UPLOADS => 0); # If sendmail isn't present, specify an SMTP host # here and below... # my $smtp_host = 'my.smtp.host'; my $upload = $r->upload; my %attachment; if ($upload) { # Send the email. my ($name) = $upload->filename =~ m!([^/\\]*$)!; %attachment = (file => $upload->tempname, name => $name); send_mail($r, From => $r->server->server_admin, To => $r->param('to'), Subject => $r->param('subject'), Data => $r->param('message'), # smtp_host => $smtp_host, attachment => \%attachment, ) or return SERVER_ERROR; print < Your message has been sent HERE } else { # Print out a web form. print < Email a file...
To:
Subject:
Attachment:
Message:


HERE } } 1;