Automation: email yourself a file


I have a computer at home which I can't access from work. I'd like to be able to view results from work that my home computer produces. The best idea I've come up with is an automated script running on my home computer that emails myself the results (from a text file or stderr/out) when complete.

I'm decent with bash (I have a linux machine) and java, so an answer using either or both of those would be ideal, but if there's something easier that's fine too.

I typically use gmail, but also have yahoo mail.

My question is this: what would be the basic steps in solving this problem? I can do the nitty gritty stuff, but can't really get the big picture of how something like this would work.

Please help.


Best Solution

Howto set up ssmtp to send through a Gmail account

Some of the steps here might seem strange at first, but the rationale is put in footnotes that should hopefully explain why.

First create a spare account on gmail which you will only use for sending email. For instance, if your normal account is, create an account with a newly created password which you only will use for this account [1].

Set up the new account to forward all email to the normal account [2] and under account settings you should add all other email adresses you use [3].

Then install ssmtp (On Debian: aptitude install ssmtp) and edit ssmtp's configuration file /etc/ssmtp/ssmtp.conf:

and configure the local mail delivery by editing /etc/ssmtp/revaliases assuming that your local login is localuser:

Make sure the two configuration files are readable to all users who should be able to send email [4].

Test the setup by e.g. mailx (On Debian: aptitude install bsd-mailx):

echo 'testing, one, two' | mailx -s 'test 1'

Hope this helps.

[1] The new gmail user name and password will be visible to everyone who can log onto your machine, so you do not want this account to be critical in any way, meaning you can close it down immediately if someone should get access to it.

[2] If some email you sent bounces back to you, you might want to know about it, and there actually exists people who will happily reply to an email from johnsmith.noreply.

[3] Gmail will rewrite the From header on the email if it does not recognise the address.

[4] Ssmtp runs as the local user who sends the email, so that user needs read access to the configuration files.