this could be configured to work, however you will need an email domain that is hosted by dreamhost and not gmail, however this doesn’t have to be the domain in question, it could be any other domain. Another thing to understand is that dreamhosts email is not hosted on your webserver, there are separate mail servers.
these loosely written steps should get you where you want to be…
1 - create an email address on a domain where email is hosted by dreamhost. (example: bbb@bbb.com)
2 - In the web panel click on the message filters section of the email group. Configure a filter for bbb@bbb.com to send emails to the shell account where the script will be running.
3 - log into your gmail account aaa@aaa.com and create a filter to forward emails that need to be processed by the script to bbb@bbb.com
Now an emaill arrives at aaa@aaa.com (gmail), a filter sends it to bbb@bbb.com (dreamhost hosted email) and a filter there forwards it on to the shell account, where your script finds it’s existence and does something with it…