Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using "mail" to send e-mails from command line on my OSX 10.6

the "< filename" however doesn't work quite well, as I don't really see the file as "attachment" on any standard e-mail client. Is there any solution for this with the standard tools that come pre-installed with OSX 10.6?

share|improve this question
up vote 1 down vote accepted

The quick and dirty way to send an attachment is to uuencode the file and mail it.

uuencode report.pdf report.pdf | mail -s "Here is the report"

If you want to do it easily and build a proper MIME encoded message, you could install mutt, and use the -a flag to attach your message.

If you don't want to install anything else, you could build your own MIME message by hand, or use the perl MIME::Entity module to help you:

use MIME::Entity;

$message = MIME::Entity->build(
  Type    => "multipart/mixed",
  From    => "me\",
  To      => "bossman\",
  Subject => "Report attached" );

$message->attach(Data=>"Here is the report, as promised.");

  Path     => "./report.pdf",
  Type     => "application/pdf",
  Encoding => "base64");

open MAIL, "| /usr/sbin/sendmail -t -oi";
close MAIL;
share|improve this answer

The easiest solution to your current situation is to use uuencode to encode the file format and mail it. Try this line:

uuencode /your/ | mail -s subject recipient@mail

Another possibility is to use perl/python scripts to do that job (maybe better), but the above solution just works(tm)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.