On Mon, 15 Sep 2003, Xu, Qiang (XSSC SGP) wrote: > Hi, Lakoduk: > > Thanks for pointing out the help webpage. Now I can use Mail::Sender to send > mails. But I have difficulties with attachments. I don't know why it always > complains that the file can't be found. My script is: > > ------------------------------------------- > use strict; > use Mail::Sender; > use CGI qw(:standard); > > my $sender = new Mail::Sender { > smtp => 'my.smtp.server', > from => '[EMAIL PROTECTED]', > on_errors => undef > } or die "Can't create the Mail::Sender object: > $Mail::Sender::Error\n"; > $sender->OpenMultipart({ > to => '[EMAIL PROTECTED]', > subject => 'Hello, I\'ll come.' > }) or die "Can't open the message: $sender->{'error_msg'}\n"; > $sender->Body; > $sender->SendEnc(<<'*ABC*'); > Here is a new module Mail::Sender. > It provides an object based interface to sending SMTP mails. > It uses a direct socket connection, so it doesn't need any additional > program. > > Enjoy, Jedi > *ABC* > $sender->Attach({ > description => 'Perl module Mail::Sender.pm', > ctype => 'application/x-zip-encoded', > encoding => 'Base64', > disposition => 'attachment; filename="Mail-Sender.zip"; type="ZIP > archive"', > file => "./Mail-Sender.zip" > }); > $sender->Close or die "Failed to send the message: > $sender->{'error_msg'}\n"; > > print header(), start_html("Sendmail"); > print p("Mail sent successfully!\n"); > print end_html(); > > exit (0); > ------------------------------------------- > > I put the file Mail-Sender.zip in the same folder as this script. The error > is: > > [Mon Sep 15 16:15:52 2003] [error] Failed to send the message: File > "./Mail-Sender.zip" not found > > Any idea on this issue? >
Does the file Mail-Sender.zip exist in the current directory when your program runs? What are its security attributes? You could easily put a check in to see. On failure then you could print out the $! to show _why_ the file can't be found. An example of this code might be: die "Mail-Sender.zip not found: $!" unless -f "Mail-Sender.zip" && -s _. The fact that it is in the same folder as the script is not the issue, the requirement is that it be in the current directory. If you cd'ed to the script's folder then you should be OK but if you did something like: perl scriptfolder\\script.pl then it won't be. **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs