Feature Controlled Email

The purpose of this project is a little hard to explain without some background information. My brother has an intellectual disability but loves computers. Trouble is, he's exceptionally skilled at finding settings panels and mucking around with everything until nothing works. Even with a guest account on Ubuntu, with all menu access to system settings removed, he still finds ways to make everything wonky. In another life he'd totally be that one guy who knows how to program every VCR. Anyways, our family is a little spread out, and as a result my brother doesn't get many opportunities to connect with everyone he loves. A few weeks ago, however, I realized that there is a way to give him e-mail access without dire consequences.

The main reason that we didn't set him up with an e-mail account in the past was because we knew that it would constantly need fixing, would have an overwhelming number of unnecessary features, and because there would be no way to limit who he could e-mail. The solution? Build a simple e-mail interface specifically to his needs.

Thanks to PHP and Gmail's IMAP features, this wasn't too difficult. Gmail offers this service for free, and because of its excellent spam filtering it seemed a no-brainer to go with them. While I do offer my code at the end of this post, here's an outline of the initial steps I took, some screenshots, as well as the features I built in.

Setting Things Up
The hardest part of all of this was getting my hosting service to enable IMAP services with SSL over port 993. I kept getting a "connection timed out" error. It took a solid week to get things working, and when I asked them to describe what they finally did to get it working, all they said was "We have enabled the specific setting related to port." So good luck! If things don't work out of the box for you, all I can say is just be persistent with tech support.

I followed this link to test things out once I had set up a Gmail account for my brother and enabled IMAP service in the Gmail settings.

Once everything was working, it didn't take long to get the interface set up.

The Interface
Here are some screen grabs of what I built. If the smudging out of every single piece of possibly personal information annoys you, too bad.

Inbox (Outbox looks the same)

Viewing a Message
Note that the "Reply to E-mail" link is only shown if the sender is in the approved list.

Replying to a Message
If someone feels crafty and enters the UID of an e-mail from a sender not on the approved list, this page will redirect back to the Inbox.

Composing a New Message
And again note that the To field is a simple drop-down list which only allows the email to be sent to the addresses on the approved list.

Sending the Message

Simple and straightforward right? Here's a brief rundown of the features

  • Easy to set up (just need to change the data in the config.php file)
  • Works with any Gmail account with IMAP enabled
  • Only allows new emails to be sent to the addresses listed in the config file
  • Only allows the user to reply to emails sent from the addresses listed in the config file
  • Supports incoming HTML emails (plain text outgoing messages only)
  • Appears to the outside world as though the user is using a normal e-mail account** (the only special interface is on the user's side)
  • Anyone can send them an email, even if they aren't on the list (hopefully this doesn't backfire)
  • Checks to make sure a message body is entered (forgives an empty subject line)
** Unfortunately I wasn't able to get SMTP sending enabled through my hosting provider, so I had to use the PHP mail() function. This hasn't caused any problems yet, but it could cause outgoing mail to be flagged as spam.

All you should need to modify is the config.php file, but everything else is fairly easy to tweak if necessary. Please note that I am still modifying the files as I find new problems.


  1. niice info...ok so I'm a bit late since you posted it. But interesting.


Post a Comment