The Straight Dope

Go Back   Straight Dope Message Board > Main > General Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2000, 01:22 PM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
OK I'm trying to send an email with an attachment with a perl script from winNT, but the most success I've had so far is an email with the 'attached' file in the body.

I've tried several modules, and they all do the same thing. Has anyone done this? Can anyone help?
Reply With Quote
Advertisements  
  #2  
Old 04-05-2000, 02:09 PM
CurtC CurtC is offline
Guest
 
Join Date: Dec 1999
You don't mention how you're trying to do it, whether piping output to sendmail, or using a module.

There are lots of mail modules available at http://www.perl.com/reference/query.cgi?mail - it looks like Mail::Sendmail will let you send attachments (of limited size).
Reply With Quote
  #3  
Old 04-05-2000, 02:22 PM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
Well it looks like I have to use a module, since I'm in NT.
Reply With Quote
  #4  
Old 04-05-2000, 08:51 PM
handy handy is offline
BANNED
 
Join Date: Mar 1999
Location: Pacific Grove, Calif
Posts: 17,493
Arent perl scripts just ASCII text? Ive got some why not just email them as text?
Reply With Quote
  #5  
Old 04-05-2000, 11:15 PM
Joe_Cool Joe_Cool is offline
BANNED
 
Join Date: Jun 1999
Posts: 2,815
Quote:
Originally posted by KarmaComa:
...I'm in NT.
Looks like we found your problem!

------------------
Joe Cool
-----
Full speed, right ahead
Don't stop, you can sleep when you're dead
Reply With Quote
  #6  
Old 04-06-2000, 10:55 AM
mrblue92 mrblue92 is offline
Guest
 
Join Date: Apr 1999
What's the nature of the error?

Can you zip the script and send it compressed?
Reply With Quote
  #7  
Old 04-06-2000, 11:43 AM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
Uh.. you guys misunderstand. I need to attach a file to an email WITH a perl script, not attach a perl script to an email.

Yes one of the problems is being in NT.

All the perl modules I can find just send the file as part of the message body, which is useless to me. If it doesn't show up as a paper clip in Outlook, then it's no good to me. I COULD do it in UNIX, but the only mail programs available are mail and mailx.

Let me rephrase the question: does anyone know how to send a bona fide email attachment from a command line? (Either UNIX or NT, I'm getting to the point where I don't care anymore).
Reply With Quote
  #8  
Old 04-06-2000, 01:21 PM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
MIME::Lite requires sendmail, which I do not have. If you do use MIME:Lite, do you know if it will send a proper attachment (i.e. paper clip in Outlook)?

I even downloaded blat, a dos command line mailer, and that shoves the file into the message body, too!
Reply With Quote
  #9  
Old 04-06-2000, 01:28 PM
Perderabo Perderabo is offline
Member
 
Join Date: Nov 1999
Location: Ashburn, Va, USA
Posts: 373
Quote:
et me rephrase the question: does anyone know how to send a bona fide email
attachment from a command line? (Either UNIX or NT, I'm getting to the point where I
don't care anymore).
I really did test that script. It really did work.
http://boards.straightdope.com/ubb/F...ML/007114.html
Reply With Quote
  #10  
Old 04-06-2000, 01:36 PM
Hunsecker Hunsecker is offline
Guest
 
Join Date: Sep 1999
Actually, I haven't used MIME::Lite, I just read the readme on cpan. So I don't know how the attachments will show up in outlook, but I would be very surprised if outlook couldn't handle mime enclosures (i get the feeling I may be giving MS too much credit though).

You may want to see if you can get the Mail::Sendmail package to work (it claims platform independence). You may be able to compose the message using MIME::Lite, then send the text it generates to Mail::Sendmail.

Other than that, I don't know of any command line programs that will do it.
Reply With Quote
  #11  
Old 04-06-2000, 03:54 PM
mrblue92 mrblue92 is offline
Guest
 
Join Date: Apr 1999
Well, do you have sendmail on your UNIX box? I've got an include file I use in Progress (a 4GL database language) to do exactly what you're talking about. Even if you aren't using Progress, the logic is only about 40 lines of codes and pretty understandable. I can post or e-mail it if you'd like. (YMMV)
Reply With Quote
  #12  
Old 04-06-2000, 04:13 PM
mrblue92 mrblue92 is offline
Guest
 
Join Date: Apr 1999
Oops... I just noticed you already said you didn't have sendmail on your UNIX... Bummer; it won't work for you then.

You could try inserting the MIME boundaries in the text of your message around your file (in your Perl script as Hunsecker suggested), but it'll start getting a little messy if you try send something other than a text file. In the case of binaries, you'd probably need to incorporate an encoding algorithm. (I've never needed to do binaries in this method.)
Reply With Quote
  #13  
Old 04-06-2000, 04:16 PM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
Perderabo: I tried your script and it gave me:

Ignoring recipients on command line with -t

Then let me input the text... it ignored the recipient, which I had (obviously) defined with a -t then -a.... and didn't send it to anyone. Why does it ignore this?

To the other person: I would love your code.. any ideas would help. My email is adking@uvic.ca. Thanks.

And thanks everyone for your continued assistance.
Reply With Quote
  #14  
Old 04-07-2000, 12:26 AM
Hunsecker Hunsecker is offline
Guest
 
Join Date: Sep 1999
You could have your script write out the mime tags directly I guess. So following the subject line, write:

Mime-Version: 1.0
Content-Type: multipart/mixed ; boundary="<put some unique text here to seperate the parts of the message, my mailer usually puts in the encoded date or something>"

--<that unique text from above>
Content-Type: text/plain; charset=us-ascii

message body

--<that unique text from above>
Content-Type: image/jpeg
Content-Description: someimage.jpg
Content-Transfer-Encoding: base64 (or uuencode or something)

repeat for each part of the message, then:

--<that unique text from above>--

(That oughtta work, I've had to muck directly with mime tags a few times but it usually ended up being trial and error)

Or, you could check www.cpan.org for a MIME module for perl. Theres gotta be one out there.
Reply With Quote
  #15  
Old 04-07-2000, 12:39 AM
Hunsecker Hunsecker is offline
Guest
 
Join Date: Sep 1999
Aah, and indeed there is a module on cpan.

MIME::Lite looks like it'll do what you want, and looks real easy too.
Reply With Quote
  #16  
Old 04-07-2000, 10:24 AM
handy handy is offline
BANNED
 
Join Date: Mar 1999
Location: Pacific Grove, Calif
Posts: 17,493
try cgi-resources.com they have anything & everything to do for it....should have just what you need for NT.
Reply With Quote
  #17  
Old 04-07-2000, 06:15 PM
WhiteNight WhiteNight is offline
Guest
 
Join Date: Sep 1999
Can you get a win32 UUEncode or Base64Encode program? If so, encode the file to attach. Then output the raw mime headers, the encoded file, and the mime footers. Should be fairly simple.

RFC 1521 describes MIME (It says it's part 1, so there's likely more.)
http://www.oac.uci.edu/indiv/ehood/M...fc1521ToC.html

That should explain how to form the headers.

If you're in doubt, grab the linux source for sendmail/etc and see how they did it.
Reply With Quote
  #18  
Old 04-07-2000, 06:23 PM
Hunsecker Hunsecker is offline
Guest
 
Join Date: Sep 1999
Just FYI, when I was poking around in CPAN earlier, I noticed that MIME: ecoder would also do encodings for a data stream.

Might be easier and safer than running an external program.
Reply With Quote
  #19  
Old 04-07-2000, 09:59 PM
Hunsecker Hunsecker is offline
Guest
 
Join Date: Sep 1999
Damn smileys. Thats MIME:ecoder of course.
Reply With Quote
  #20  
Old 04-14-2000, 11:00 AM
mrblue92 mrblue92 is offline
Guest
 
Join Date: Apr 1999
Any luck, KC?
Reply With Quote
  #21  
Old 04-14-2000, 11:08 AM
KarmaComa KarmaComa is offline
Guest
 
Join Date: Mar 2000
No.. I tried messing around with MIME headers, editing perl modules, etc., but then said screw it, because it's not something that has to be done.
Reply With Quote
Reply



Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Send questions for Cecil Adams to: cecil@chicagoreader.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright 2013 Sun-Times Media, LLC.