Rails doesn't care frome where you get your emails, you just have to forward them using script/runner YourMailer.receive(email) or more probably YourMailer.receive(STDIN.read). Personally I use getmail, you can find some docs on the wiki. The code you posted is for _sending_ emails. Receiving with SMTP is quite hard, you need POP3/imap.
Have fun ! ngw