Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added framework support for processing incoming emails with an Action…

… Mailer class.

git-svn-id: 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 800b86e4c7464021d07dc763c1890b1bb49dacd4 1 parent 425aa50
@dhh dhh authored
Showing with 41 additions and 0 deletions.
  1. +5 −0 actionmailer/CHANGELOG
  2. +36 −0 actionmailer/README
5 actionmailer/CHANGELOG
@@ -1,3 +1,8 @@
+* Added framework support for processing incoming emails with an Action Mailer class.
*0.7.1* (7th March, 2005)
* Bind to newest Action Pack (1.5.1)
36 actionmailer/README
@@ -5,6 +5,12 @@ are used to consolidate code for sending out forgotten passwords, welcoming
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
+Additionally, an Action Mailer class can be used to process incoming email,
+such as allowing a weblog to accept new posts from an email (which could even
+have been sent from a phone).
+== Sending emails
The framework works by setting up all the email details, except the body,
in methods on the service layer. Subject, recipients, sender, and timestamp
are all set up this way. An example of such a method:
@@ -47,6 +53,36 @@ ApplicationMailer, it would look like this:
ApplicationMailer.deliver_signed_up("") # sends the email"") # won't work!
+== Receiving emails
+To receive emails, you need to implement a public instance method called receive that takes a
+tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns
+into the tmail object and calls the receive instance method.
+ class Mailman < ActionMailer::Base
+ def receive(email)
+ page = Page.find_by_address(
+ page.emails.create(
+ :subject => email.unquoted_subject, :body => email.unquoted_body_with_all_parts
+ )
+ if email.has_attachments?
+ for attachment in email.attachments
+ page.attachments.create({
+ :file => attachment, :description => email.unquoted_subject
+ })
+ end
+ end
+ end
+ end
+This Mailman can be the target for Postfix. In Rails, you would use the runner like this:
+ ./script/runner 'Mailman.receive('
== Dependencies

0 comments on commit 800b86e

Please sign in to comment.
Something went wrong with that request. Please try again.