Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERL SendMail Attachment

Status
Not open for further replies.

jbarkawi

Programmer
Joined
Jul 27, 2005
Messages
3
Location
US
Hello,

I have been working on a simple Perl script that would allow people to send an e-mail and attach a file from thier computer. The server I am running is UNIX I believe. The problem is that I can attach files to the e-mail that are on the server, ie. "/home/ However, for my purposes I need the user to be able to attach a file from thier comptuer, ie. "C:\text.txt". When I try to do this, I recieve an 500 Internal Server Error. Could you please assist me in doing this? The script I wrote is located Below.

###########################################################

#!/usr/bin/perl

use MIME::Lite;
use Net::SMTP;
use strict;
use warnings;

my $from_address = 'jbarkawi@infinitetiers.com';
my $to_address = 'jbarkawi@infinitetiers.com';
my $subject = 'MIME Net::SMTP test';
my $mime_type = 'TEXT';
my $message = "Hello world!\n";

my $mime_msg = MIME::Lite->new(
From =>$from_address,
To =>$to_address,
Subject => $subject,
Type => $mime_type,
Data => $message
);

my $filename = 'C:\test.txt';

$mime_msg->attach(
Type => "application/txt",
Encoding => "base64",
Path => $filename,
Filename => "resume.txt");


MIME::Lite->send('smtp', 'localhost', Timeout =>20);

$mime_msg->send;

##########################################################

With kind regards,

Joe Barkawi
Software Engineer
Infinite Tiers, Inc.
 
Joe,

have a look in the FAQ section about uploading files.

You need to upload the file from the local machine before you can send it as an attachment

HTH
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top