Hi Richard,
If for one minute I 'ignore' the first part of your question...
It is relatively straightforward to Automate your Mac from remote emails...
To start we can just add in a Rule into 'Mail.app' that will run an AppleScript when it gets a 'certain' email...
Go to Mail-->Preferences--> Rules
As you can see I have put in a few sample Rules...
Now you need to click on the add rule and then name it and navigate to the AppleScript that you want it to run...it must be an AppleScript !
As you can see from the pics above, you need to think about what will trigger the AppleScript...you don't want a piece of Spam setting of your Shutdown--Restart etc workflows...
If you had done an elabourate workflow in Automator, then just save that as an Application, and use this as an the AppleScript, (replacing the name),
Code:
tell application "myWorkflowApp"
activate
end tell
You can replace the myWorkflowApp with any Application on your Mac.
For all of this to work, Mail App must be running, and the User logged in, set Mail to check for new mail every 5 minutes.
Then where ever you are you can send an Email with your 'code words' in to get you Mac to do something...
So on one of my Mac's at home I have a Rule set up that does this...
On receipt of the 'special email', this rule kicks in..
1) Reply to message-with the text "Instructions received Restart in Progress"
This sends me an email message telling me that the remote Mac has got the email and is running the Script.
2) Run AppleScript-this has a delay at the beginning to ensure that the 'message' above gets sent !
Code:
delay 60
tell Application "System Events"
restart
end tell
So that all works fine !
Now back to the first part of your question...
If you log out then all your Apps quit !
So one way, if there are other "Users" on that Computer, you need to enable Fast User Switching and 'switch' to another user before leaving...this will keep Mail open in your 'real user account', checking for any Mail you send, when Mail receives this email it will go off and run your Script...depending on what you want it to do it may or may work. A restart command sent to the User in the background will not restart the Mac, (this may be possible via a shell script) it would have to be sent to the 'Front most' active user, if you see what I mean !
...if you are telling your Mac to restart, then depending on what options you have set in the Accounts Pref Pane will determine who (which User) gets logged back in after the restart !
Another way would be to enable FileVault. If you have stuff on your Computer that you don't want colleagues, siblings etc to see then you can always use FileVault to protect your data. I'm not a big fan of FileVault cause it can tend to break other things...
The only other alternative is to enable SSH on your Mac, this will enable you to login to your Mac remotely and do what ever you want, as long as the Mac is turned on, it doesn't need to be logged in !
But to do this you would need a computer or a PDA that has Internet access to send the commands to the Mac, you would also need to know the IP address of that Mac !
And you would also have to allow SSH 'in' on your Firewall or/and Router...
Maybe you could create another 'User' on that machine that you would login to when leaving your home/office thus protecting your 'real' account, this 'fake' account could then be set to 'listen' for your remote commands...you could set up a free email account just for that user...
All depends on how much you 'don't want' someone else accessing your Mac ?
regards
Ric