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.
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
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
Sending the Message
- 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.