CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
problems sending attachments

 



jacksonpt
Deleted

Jun 30, 2000, 6:58 AM

Post #1 of 2 (597 views)
problems sending attachments Can't Post

I have never worked with MIME:Lite before, so I am unsure about any initializing or setup lines that may need to be run. Here is what I have to this point:

~~~~~~~~~~~~~~~~~~~~~~~~~~~

#!/usr/bin/perl

$mailagent = '/usr/lib/sendmail';

&parse_form_data(*input);
&print_table;
&setup_email;
&notify_user;
exit(0);

sub parse_form_data {
# pulls in all data from form
}

sub print_table {
# overwrites an existing HTML file
}


sub setup_email {
# tries to send HTML file as attachment
open (MAIL, "|$mailagent $recipient") | | die "Can't open $mailagent!\n";
$message = MIME::Lite->new(
From => 'jtaylor@binghamton.edu',
To => 'jacksonpt@stny.rr.com',
Subject => 'Job Listing',
Type => 'text/html',
Encoding => 'base64',
Path => 'test.htm'
);
$message->send;
}


sub notify_user {
#displays confirmation message to user
}

~~~~~~~~~~~~~~~~~~~~~~~~~~

I am getting a server error (surprise, surprise), but with my lack of MIME:Lite experience, I have no idea what the problem might be.

Any suggestions would be appreciated.
-Jackson


Cure
User

Jul 8, 2000, 9:10 AM

Post #2 of 2 (597 views)
Re: problems sending attachments [In reply to] Can't Post

#!/usr/bin/perl -w

use CGI qw(:standard);
use MIME::Lite;


if ( param('submit'))
{
my $fh;
if( $fh = upload('uploaded_file'))
{
binmode $fh;

my $content = do { local $/; <$fh>; };

my $msg = new MIME::Lite( From => 'root@localhost',
To => 'you@texas.net',
Subject =>'A Test Message ...',
Type =>'multipart/mixed');

$msg->attach(Type => 'TEXT',
Data => 'The test attachment');
$msg->attach(Type => 'application/x-unknown',
Data => $content,
Filename => $fh);

$msg->send;

print header,start_html,h1("Sent ..."),end_html;
}
else
{
print header,start_html,h1("Oops ..."),$fh,end_html;
}
}
else
{
print header,
start_html,
start_multipart_form,
filefield(-name=>'uploaded_file'),
submit(-name => 'submit'),
end_html;
}

Cure

[This message has been edited by Cure (edited 07-08-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives