[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

attaching a file to e-mail

i have a script that receives and saves a file on my server and sends an e-mail with all form data including a link to the file saved. how do i instead attach the file to the e-mail ?

sorry about the few points, but its all i have right now :-)

0
hatecapletters
Asked:
hatecapletters
1 Solution
 
malecCommented:
Use uuencode on that file before you send it. Like this:
 uuencode in_file_name out_file_name | /usr/bin/sendmail <your@email>

Unix/linux. virtualave is unix.

On wintel you could zip it and then send.
0
 
malecCommented:
use Mail::Mailer;
   $mailer= Mail::Mailer->new();
   mailer->open( {From => $me,
                  To   => $you,
                  Subject => $subj,
               })
   or die "Can't open $! \n";
print $mailer $msg;
$mailer->close();
0
 
hatecaplettersAuthor Commented:
looks good, but where do i specify what file i want to attach ?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
malecCommented:
in_file_name in 1-st case and $msg in 2-nd
0
 
hatecaplettersAuthor Commented:
I'm sorry, but I have some problems seeing how that should attach the file to the e-mail with the rest of the form data..
0
 
malecCommented:
well, you asked how to attach file and I told you. As for form data it can also be saved in file.

sendmail is what you usually use to send mail and uuencode makes an attachment out of file, binary or text...

If you still don't see it - forget it.
0
 
hatecaplettersAuthor Commented:
*forgotten*
0
 
ozoCommented:
use MIME::Lite;
0
 
Kim RyanIT ConsultantCommented:
There are several CPAN packages that handle mail attachments. As ozo suggested, MIME::Lite will work, as will Mail::Sender. Mail::Mailer will not handle attachments as far as I know.

You will need to download and install this module and 2 other supporting ones, see http://jenda.krynicky.cz/#Mail::Sender for details.

use Mail::Sender;
     
$sender = new Mail::Sender
{
   smtp => 'mail.yourdomain.com',
   from => 'you@xyz.com'
};
$sender->MailFile(
{
   to => 'some@address.com',
   subject => 'your subject',
   msg => "your message",
   file => 'filename.txt'
});

0
 
hatecaplettersAuthor Commented:
short, but just what I needed (having read some documentation for mime::lite)
:-)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now