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:
Using MIME::Lite

 



kidd
User

Jul 15, 2002, 1:12 PM

Post #1 of 3 (347 views)
Using MIME::Lite Can't Post

Hello...

Can someone tell me why doesnt this work...


Code
 
my $msg = MIME::Lite->new(
From =>$Input{'email'},
To =>$Input{'sender'},
Subject =>'Envío por el anuncio',
Type =>'multipart/mixed'
);


### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>"$Input{'message'}"
);

open(FILE, "attach.txt");
my @lines = <FILE>;
close(FILE);

foreach my $line(@lines){

my $path = "/u19/ben/boon/uploads/$line";

$msg->attach(Type =>'image/gif',
Path =>$path,
Filename =>$line,
Disposition => 'attachment'
);

}

$msg->send;

print "Content-type: text/html\n\n";
print "<h1>DONE</h1>";


What I have in my "attach.txt" text are the file names of pictures...the two of them in .jpg...

I know it's not a problem with the location of the library, and it isnt the sendmail path...

It would be great if you could tell me what Im doing wrong...

THANKS

"So you want to be a cowboy
Well you know it's more than just a ride
Guess you got to know the real thing
If you want to know the other side
Ain't nobody riding shotgun
In this world tonight"


davorg
Thaumaturge / Moderator

Jul 16, 2002, 1:07 AM

Post #2 of 3 (343 views)
Re: [kidd] Using MIME::Lite [In reply to] Can't Post

The lines in your attach.txt file will have newline characters on the end. Your filenames almost certainly don't. ou probably need to "chomp" $line before you try to use it.

'-w' on your shebang line would have told you what the problem was.

Also, you should _always_ check the return value from a call to "open".

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


kidd
User

Jul 16, 2002, 6:58 AM

Post #3 of 3 (340 views)
Re: [davorg] Using MIME::Lite [In reply to] Can't Post

Thanks davorg for your reply....

In fact, the problem was that I forgot to use chomp, but now it works great...

"So you want to be a cowboy
Well you know it's more than just a ride
Guess you got to know the real thing
If you want to know the other side
Ain't nobody riding shotgun
In this world tonight"

 
 


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

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