On Sat, Dec 01, 2012 at 05:12:05AM +0000, Jeffery Small wrote:
> Within a script, I would like to use mutt to automatically email a JPEG
> file as an attachment without user intervention.  Is there any way to
> accomplish this?  (And if not with mutt, then possibly with mail(1) or
> mailx(?))
> 
> When I try to use the -a option to mutt, it always responds: "unable to
> attach file".
> 
> Also, from the commandline, I don't know how to tell mutt to base64 encode
> the file.  I could encode the file manually before passing it to mutt, but
> I'm still at a loss as to how to get mutt to properly attach it to the
> message.

You shouldn't need to do any special encoding, and mutt -a should do
what you want.

What is the exact command line you're using, and what's the *full*
error? Searching for the error message you're getting briefly, it looks
like this error may come up when the -a argument is specified before the
recipient rather than after (and if that's the case, you'll notice that
the recipient address, rather than the filename, is what it can't
attach). Otherwise, it could be a permissions or file path related
problem.

Something like this should work:
% echo 'This is my body' | mutt -s 'file attached' \ 
      [email protected] -a image001.jpg 

Whereas this gives an error:
% echo 'This is my body' | mutt -s 'file attached' -a \
   image001.jpg [email protected]
Can't stat [email protected]: No such file or directory
[email protected]: unable to attach file.

w

Reply via email to