Gossamer Forum
Home : General : Perl Programming :

Email File Attachments

Quote Reply
Email File Attachments
Hello,

I recently downloaded birdcast.cgi and modified it so it sends html mail. I would like to know what the MIME formatting line is for file attachments is though. When someone fills out a form, to make sure their email address is correct, it will send the zip file to their address. I would like to know how to do this. Any help would be great.

------------------
Sincerely,
Blair Ireland
bireland@visuart-design.com
www.thescripts.com

Quote Reply
Re: Email File Attachments In reply to
I wouldn't recommend trying to write one on your own. Instead download and install the Mime::Lite module. Then you can do something like this (syntax is a little off, see documentation):

Code:
my $mail = new MIME::Lite (
To => 'to@somewhere.com',
From => 'from@somebody.com',
Subject => 'Your file sir.',
Data => 'Here is the file you requested.'
);
$mail->attach (
Path => 'somefile.gif',
Encoding => 'base64',
Type => 'image/gif'
);
$mail->send;

Cheers,

Alex
Quote Reply
Re: Email File Attachments In reply to
Alex, is there a simplier way to do this without installing Mime::Lite module?

Thank you,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: Email File Attachments In reply to
Hello,

Ok, I have the MIME::Lite Module installed. Now I would like to make attachments. The thing is, under MIME type, I do not know what the type of file is to put for zip files. Anyone know?

Thanks a bunch

------------------
Sincerely,
Blair Ireland
bireland@visuart-design.com
www.thescripts.com

Quote Reply
Re: Email File Attachments In reply to
I think it's:
Code:
Type => 'binary/zip'

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: Email File Attachments In reply to
Thanks.

The problem is that the file is attached all nice, fine and dandy. The problem is that there are serious errors when I try to run the attached file. It gives you winzip errors and will not work,

------------------
Sincerely,
Blair Ireland
bireland@visuart-design.com
www.thescripts.com

Quote Reply
Re: Email File Attachments In reply to
Sorry, I was wrong.
Ok this info (should work) is from some FAQ I have:


For ZIP files:
Code:
Type => 'application/x-zip-compressed'

For EXE files:
Code:
Type => 'application/octet-stream'

For MS Documents .DOC files:
Code:
Type => 'application/msword'

For .CGI files:
Code:
Type => 'application/octet-stream'

For Microsoft Excel Comma Separated Values Files .CSV:
Code:
Type => 'application/x-unknown-content-type-Excel.CSV'

For Plain Text:
Code:
Type => 'text/plain'

For .HTML and .HTM files:
Code:
Type => 'text/html'

For .MP3 and .WAV files:
Code:
Type => 'application/octet-stream'

Please correct me, if I'm wrong at some point Smile

Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: Email File Attachments In reply to
Thanks alot!

That should be the source of my problem for the attachments as well, right?