How can I send an email from the command line?

Kevin O'Gorman kogorman at gmail.com
Sun Feb 13 02:26:16 UTC 2005


All the systems I use, including Solaris, have mailx.  It's old but
reliable and small.
For this purpose you don't need the new bells and whistles, which mostly have
to do with the user interface.  When scripting you won't be using a
user interface,
so this is perfect.

Under bash or tcsh, you can use a "here-document" like so

prompt % mailx -s "My subject" -b my-bcc-address
real-recipient at his.isp.com <<EOF
There are other switches, like real CC: addresses, but this is what I
usually use.
Whatever message you would like to send goes here
and it can be as long as you like.  It ends with a line
containing only the token that followed the "<<" thingie on the
command line.  Like so:
EOF

prompt %


On Sat, 12 Feb 2005 10:39:19 +0000, Neil Woolford
<neil at neilwoolford.co.uk> wrote:
> Hi all,
> 
> I'd like to semi-automatically send a short email of system information
> from my brother's computer to mine.  The nearer I can get to a 'one
> click' process the better.
> 
> Evolution works fine on my brother's machine, and he knows how to use
> the basic mail features.  So if I could get a script to start evolution
> and fill in a message, he could easily send it to me.  Frustratingly,
> while I can find how to initiate a message from the command line
> ("evolution mailto:joe at soap.com"), I can't find out how to insert text
> into the message from the command line.  This must be possible, as Gnome
> does it when sending an invitation to a VNC session.  I can't find any
> proper man pages about using Evolution from the command line, so I'm
> stuck.
> 
> Any suggestions?
> 
> Neil
> 
> PS I have already tried 'mail' at the command line;  this worked for
> sending mails between local users on my machine, but although a data
> package did appear to leave when I tried to send to a full email address
> via my ISP, nothing arrived and no error messages were given.  (I
> understand that other people's mileage varies here...).
> 
> If someone could point me in the right direction to configure this so
> that it works, that would be another way to solve the problem.
> 
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> http://lists.ubuntu.com/mailman/listinfo/ubuntu-users
> 


-- 
Go back to the top: I almost always top-post
Kevin O'Gorman, PhD




More information about the ubuntu-users mailing list