How can I send an email from the command line?

larry price laprice at gmail.com
Sat Feb 12 16:51:36 UTC 2005


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.

This is a job for a script, look at the docs for python, especially
the smtplib module.

If you want to send nicely formatted emails with pretty printed tables
and so on you'll need to understand the email package which can help
you build messages of arbitrary complexity (html documents pictures
attachments)

> 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.

to do this use a pipeline 

mail -s"the computer is borked" me at example.com < borkenlist

deconstructed:
 the contents of the file borkenlist are fed to mail's standard input
and sent to me at example.com with a subject header "the computer is
borked"

> 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...).

this has to do with how mail gets transferred between machines, and
the fact that most ISP's are (rightly) paranoid about accepting mail
that isn't absolutely kosher.

You can test your ISP's mail server using the old telnet mailhost 25
trick and see if they are letting you send to that email address.

But more than likely you haven't configured postfix on the localhost correctly.


-- 
http://Zoneverte.org -- information explained
Do you know what your IT infrastructure does?




More information about the ubuntu-users mailing list