Apple, Journal

Sending Email and Receiving Spam-Free Mail on the iPhone

The past few days with the iPhone have been quite enjoyable, and I’m getting more and more excited about developing applications for the iPhone, even if they are only just Web apps for the time being. This device brings me back to the days when I was doing hardcore Newton development. Yes, for me, the spirit of Newton lives on in the iPhone!

One thing that I’m excited about having again is wireless email access on a handheld device. In the late 90’s, I used a Metricom Ricochet modem that was velcro’ed to my Newton to get email. Over the years, I’ve used several more devices, such as the Blackberry 957, the Palm i705, and the Palm Treo 700w, but none of them have stuck with me. I could have seen myself using the Crackberry, but I hated having to pay an extra $40/month for what amounted to an email machine. With the iPhone, I have no problem spending an extra $20/month since I get a whole lot more for my money — email, iPod, phone, and Internet.

I ran into some snags getting my email configured properly on my iPhone, namely in being able to send mail from the phone and in handling spam. Since these topics might be general interest, here’s how I dealt with them:

SMTP

Having the iPhone grab account information from my Mac is great, but there’s a catch if you don’t use one of the pre-configured accounts like Yahoo! Mail, AOL, Gmail. If the iPhone is unable to contact the SMTP server listed in your account, you won’t be able to send any email from the phone!

At home, I use Comcast cable for Internet. Comcast blocks SMTP traffic on port 25 except for their own server at smtp.comcast.net. Because of this, my tow.com account is configured to use Comcast’s SMTP server. When I synced that mail account to the iPhone, it copied over that value for the SMTP server. I composed several emails over the past two days which remained in the Out Box, leading me to conclude that smtp.comcast.net isn’t accessible from the iPhone when on the Edge network.

For the past year, I’ve been forwarding my mail at tow.com to Gmail for archival purposes. I learned today that Gmail has a publicly available SMTP server on port 465 or 587 that you can use, provided you have a Gmail account. I configured my tow.com email account to Gmail’s SMTP server, and now mail is being sent just fine from both my desktop and iPhone.

However, when I received mail sent through Gmail’s server, the From address was my Gmail address instead of my tow.com address. To fix that, I had to go into my Gmail account settings and set up an alternate From address.

SPAM Woes

The second problem is that the iPhone’s Email application doesn’t have any junk mail filtering capabilities. I get a ton of spam, and all of those messages were flooding my iPhone’s Inbox. This problem is compounded by the fact that the iPhone doesn’t have any way to select multiple email messages for deletion!

Before today, my junk mail handling was done via a combination of SpamAssassin on tow.com and Mac OS X’s Junk Mail filtering algorithms. Mail came into tow.com to be tagged by SpamAssassin before being downloaded and processed again by Mac OS X mail. I needed to find a way to filter my messages before they got the iPhone. Deleting mail on the server first wasn’t an option since I didn’t want to inadvertently delete any false positives.

Again, Gmail came to the rescue. By setting Gmail to forward mail to an second account on tow.com, I’m able to have Gmail filter my messages before they reach the iPhone. To accomplish this, I had to:

  1. Forward all incoming mail to tow.com to Gmail
  2. Forward mail from Gmail to my second tow.com account
  3. Set the iPhone to retrieve mail from my second tow.com account

This approach has given me many benefits. I have multiple copies of the mail — for data redundancy purposes — on my Mac, my iPhone, and the Web. I have arguably better spam filtering via Gmail. I can now send email fine from my iPhone and my Macs without having to worry about SMTP port blocking. Finally, all my mail appears to come from one account at tow.com. Life is good!

Standard

12 thoughts on “Sending Email and Receiving Spam-Free Mail on the iPhone

  1. antti says:

    You wrote that deleting mail on server is not a solution. Sounds reasonable. But still having your mail do a roundtrip to Google does not sound the most zen approach. (Inefficient use of the network. single point of failure, …)

    As you say, the approach has several advantages too. In the interest of completeness I’d like to present some other alternatives — perhaps some other reader may find them useful.

    I don’t know what your server setup is like, but if you have procmail or equivalent at your disposal, there are at least two ways to achieve the same result:

    Alternative 1: Based on spamassasin’s judgement, move the suspected spam to a Junk folder. You wouldn’t delete anything, but your inbox would be relatively spamless.

    Alternative 2: Based on spamassasn, forward non-spam to the other tow.com address.

    Regarding SpamAssassin:

    Some people have far too low opinions about its efficiency. The reason behind this is that by default, SpamAssassin does not trust the bayesian classifier very much. However, when properly trained and properly scored, it is rock-solid. I used a week’s worth of spam for training and set the rule BAYES_99 to 10 points (and BAYES_80 to 4).

    With those settingss I have virtually no false positives and less than 1 false negative / week.

  2. Good point about the inefficiencies of my approach. Including your alternatives, I might also use Google Domain for my site, though I can’t do that right now since other people are relying on my site for email. In the meantime, I’ll investigate your suggestion about using a procmail recipe to perform some pre-filtering.

  3. Bill Nalen says:

    I’m not getting the gmail alternate stuff. You have your iphone checking pop on tow.com and your iphone sending smtp on gmail. I don’t see how that messes up the reply to stuff, or does it add the reply to stuff based on the gmail smtp rather than what is sent out through the iphone? Either way, I tried to setup the same thing, I created a new gmail account, added my own domain as an alternate mail address, verified it and set it as the default. Now when I reply to an email from the gmail account on the gmail web site all works fine, when I reply to the email sent it has the right domain name. However, on my iphone I setup the gmail account (didn’t just do the smtp thing) the reply to doesn’t change, it’s always @gmail.com. Is there something I’m missing? This is just to get around comcast blocking port 25 right? Seems they aren’t blocking that port in my area so I can use my own domain smtp and the reply to works just fine.

    I’m really interested to see how people setup their email on their iphones. I might just have to switch to imap and deal with the slowness on the desktop side so that I don’t have to delete mail on the iphone and on the desktop.

  4. Actually, I’m using IMAP on tow.com.

    On the iPhone, I did not set up a Gmail account. Rather, I am communicating with the tow.com IMAP server. I suspect this is the reason why your Gmail address is showing up since the iPhone’s mail app.

    My approach is not just to get around the SMTP thing. It handles:

    * Better spam filtering over Spam Assassin (at least the way I had configured it on my server)
    * SMTP Port Blocking by Comcast
    * From address all from the same address

  5. Bill Nalen says:

    Okay, so all email to tow.com goes to gmail just for a backup. You read on the desktop/iphone via imap so any changes made on either side is propagated to the other side automatically. You send mail on the desktop via comcast’s smtp and on the iphone via gmail’s smtp. Mail is getting routed server to server to handle the spam problem. Is that about right?

    I’ll try that setup and see what happens. There must be something about using a gmail account on the iphone that negates the gmail preference for the “from” field change I made.

  6. Actually, it’s more like this right now:

    Mail -> tow.com account #1 -> GMail -> (spam filtering) -> tow.com account #2

    iPhone -> tow.com account #2
    Mac -> tow.com account #2

    I could simplify this by using Google Apps for Domains and have mail to tow.com directly to GMail before being filtered and sent back to tow.com. A task for another day.

  7. you guys have completely lost me. i have the same exact problem with my junk mail in the iphone and deleting each one at a time in three email folders is a pain — but setting up a whole newaccount (for all three accounts) sounds totally crazy?! At least forme it is because you guysare using some lingo I am not too hip to. I barely remember how i set up my pop3 accounts in the firstplace.
    Anyone out there have any other sugestions?like allowingmy mail.app to delete junk automatically rather then letting it sit in the junk email folder for 1 day?

  8. Solving iPhone problem using GMail’s from address: This post describes a procedure to access a GMail account on your iPhone and (a) specify a FROM address which has a domain other than @google.com and (b) prevents the iPhone from reading ALL recent email, whether read, archived or already deleted!

  9. Gad Elmoznino says:

    Hi, I also use the Gmail SMTP server to send mail from the email application on the iphone and from an email account set up to get pop mail off my ISP’s server. In other words, I read my own-domain based mail but when I compose a message from that account it sends it out via the gmail SMTP server (for some reason, sending it through my ISP SMTP server was extremely slow and this is why I went the gmail route).

    My problem, however, is that every email I send from the iphone has the word SPAM mysteriously added to the subject of my email. In other words, the recipiant gets the email fine but the word SPAM is at the begining of the subject. I am not sure why this is or at which point in the process it gets added. It doesnt seem to be the recipient because it happens to every recipient and at different ISPs etc.

    any ideas?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s