User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Send email to raspberry pi to do tasks

Sat Jan 10, 2015 4:52 pm

I will do what I can.

The key to all of it is the .forward file in the recepients home dir.

Pipeing the email into a script from within the .forward file is what is needed.

There are a few examples.

Let me know if you get stuck.

Here is a quick and easy guide.

http://www.activecampaign.com/help/forw ... pe-script/
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Send email to raspberry pi to do tasks

Sat Jan 10, 2015 6:09 pm

I just grabbed a spare pi that I have exim installed on and created a .forward file for the user "pi"

in it says this:

Code: Select all

| /home/pi/myscript
then I created a script in pi's home dir that says this:

Code: Select all

#!/bin/sh
cat >> /tmp/pi-msg
date >> /tmp/msgdate

Then I made the script executable
chmod 755 /home/pi/myscript

It worked.

Now what you want the script to do is up to you.

a cut and a grep should be all that you need to execute any command.

since exim replaces sendmail you can do the following to see what is happening

/usr/lib/sendmail -v pi

type some stuff
end with a dot on a line all by itself
.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Return to “Networking and servers”