The following is a quick modification of an older script which I've now rewritten to use the CGI::Upload module - This little script will accept uploaded files of a specified mime type, in this example image/gif, and send them through to the email address specified.
#!/usr/bin/perl -Tw
use EMAIL => 'user@yourdomain.com';
use SERVER => 'mail.yourdomain.com';
use CGI;
use CGI::Upload;
use Mail::Mailer;
use Net::SMTP;
use strict;
my $cgi = CGI->new;
my $upload = CGI::Upload->new( $cgi );
if ( $upload->mime_type('upload') eq 'image/gif' ) {
my $mail = Mail::Mailer->new(
'smtp', Server => SERVER
);
$mail->open({
'To' => EMAIL,
'From' => 'root@yourdomain.com'
});
my $buffer;
my @results;
my $fh = $upload->file_handle('upload');
while (read($fh, $buffer, 45)) {
push (@results, pack("u", $buffer));
}
$fh->close;
print $mail
join "",
"begin 600 " . $upload->file_name('upload') . "\n",
@results,
"end\n\n";
$mail->close;
}
print STDOUT $cgi->redirect( $ENV{'HTTP_REFERER'} );
exit 0;
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|