[Techtalk] auto email with attachments

Telsa Gwynne telsa at aloss.ukuu.org.uk
Thu Jul 5 20:43:40 UTC 2007


Ar Thu, Jul 05, 2007 at 11:09:58AM -0700, ysgrifennodd gossamer axe:
> I was curious if anyone has done this.  I want to auto email with
> attachments (pictures) using the mail app.  So say I have a directory 
[five files]
> and I want to auto email these to an email address without having to send
> each one by hand.  I was thinking of a script with a pause in it with sleep.
> I have to send these one at a time for yahoos file size limit.
> 
> for file in *
> do
> ...
> sleep 60
> ...
> 
> I've looked at the mail man page but didn't see anything about adding file
> attachments with mail.

First thing first: it is possible that you have different man pages for 
'mail' and 'mailx'. Always worth checking. (If you do, it is for ancient
historical reasons.) 

To mail text files around, I used to do something along the lines of

  mail -s "This is a subject line" someone at somewhere.tld < filename-here

(Erm, I think! It's a while since I have needed this!) But that's for
text, and I don't think you can just cat a jpg into a message body like
that. 

These days, I use mutt, and the manual (the big huge one online or
in /usr/share/doc/, not the one at 'man mutt') suggests: 

http://www.mutt.org/doc/manual/manual-6.html#ss6.1

  Mutt also supports a ``batch'' mode to send prepared messages. Simply 
  redirect input from the file you wish to send. For example,

  mutt -s "data set for run #2" professor at bigschool.edu < ~/run2.dat

  This command will send a message to ``professor at bigschool.edu'' with 
  a subject of ``data set for run #2''. In the body of the message will 
  be the contents of the file ``~/run2.dat''.

The man page (ie, with man mutt) also mentions -i (included message
body) and -a (attachment). If it turns out that redirecting jpg files
isn't a good idea in mutt either, perhaps one of those may help?

Apparently there is an application called "mailto" which will send
files via email, but it isn't usually installed by default. Unfortunately,
I tried to google it and the results are hopeless: "mail", "forward",
"image", "mailto" and so on are not useful search terms :( 

But good luck, if you do try to hunt it down!

Telsa



More information about the Techtalk mailing list