How can I send an email from the command line?
anthony hologounis
ahologounis at cox.net
Sat Feb 12 19:55:27 UTC 2005
On Saturday 12 February 2005 2:39 am, Neil Woolford 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.
I do this automatically with a cron script.
This is an example
#!/bin/sh
w>/root/bin/df_info.txt
date>> /root/bin/df_info.txt
echo 'This is from My Brothers Machine!' >>/root/bin/df_info.txt
df -H>> /root/bin/df_info.txt
cat /root/bin/df_info.txt | mail -s 'Info from My Brothers Machine'
you at somewhere.com
I am doing this as root but a regular user can do the same
'w' returns system uptime and load averages which get copied
to /root/bin/df_info.txt
'date' returns the date and is appended to /root/bin/df_info.txt
notice the >> which appends
I then echo some text which gets appended
I then run 'df' which tells me what my harddrives are doing, that gets
appended
cat the file and pipe it to the mail command
I run the script from cron
#Run some command every hour
*/60 * * * * /run/some/command
hope this helps
Anthony
More information about the ubuntu-users
mailing list