github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

pluginaweek / has_emails

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 11
    • 1
  • Source
  • Commits
  • Network (1)
  • Downloads (9)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (9)
    • v0.3.0
    • v0.2.1
    • v0.2.0
    • v0.1.4
    • v0.1.3
    • v0.1.2
    • v0.1.1
    • v0.1.0
    • v0.0.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Demonstrates a reference implementation for sending emails with logging and asynchronous support — Read more

  cancel

http://www.pluginaweek.org

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add gemspec 
obrie (author)
Tue Jun 09 20:32:18 -0700 2009
commit  67416f7428c46f1443b3c406c1fce112eebb08c5
tree    8d2ff4fec8ad403ec14c9621b8c558c1dd4a5840
parent  044d817253094d49b4a2a9ca8173d45f443b7080
has_emails /
name age
history
message
file .gitignore Fri Jul 04 15:48:21 -0700 2008 Ignore test/app_root/script [obrie]
file CHANGELOG.rdoc Sun Apr 19 12:55:08 -0700 2009 Add missing date from 0.3.0 release [obrie]
file LICENSE Sun Apr 19 12:29:17 -0700 2009 Update license [obrie]
file README.rdoc Sun Apr 19 12:53:01 -0700 2009 Add compatibility with has_messages 0.4.0 / Rai... [obrie]
file Rakefile Tue Jun 09 20:32:18 -0700 2009 Add gemspec [obrie]
directory app/ Sun Apr 19 12:53:01 -0700 2009 Add compatibility with has_messages 0.4.0 / Rai... [obrie]
directory db/ Sun May 04 16:14:45 -0700 2008 Update to latest has_messages api Simplify by r... [obrie]
file has_emails.gemspec Tue Jun 09 20:32:18 -0700 2009 Add gemspec [obrie]
file init.rb Mon Jul 30 11:42:09 -0700 2007 Initial release [obrie]
directory lib/ Sun Apr 19 12:53:01 -0700 2009 Add compatibility with has_messages 0.4.0 / Rai... [obrie]
directory test/ Sun Apr 19 12:53:01 -0700 2009 Add compatibility with has_messages 0.4.0 / Rai... [obrie]
README.rdoc

has_emails

has_emails demonstrates a reference implementation for sending emails with logging and asynchronous support.

Resources

API

  • api.pluginaweek.org/has_emails

Bugs

  • pluginaweek.lighthouseapp.com/projects/13272-has_emails

Development

  • github.com/pluginaweek/has_emails

Source

  • git://github.com/pluginaweek/has_emails.git

Description

Emailing between users and other parts of a system is a fairly common feature in web applications, especially for those that support social networking. Emailing doesn’t necessarily need to be between users, but can also act as a way for the web application to send notices and other notifications to users.

Rails already provides ActionMailer as a way of sending emails. However, the framework does not provide an easy way to persist emails, track their status, and process them asynchronously. Designing and building a framework that supports this can be complex and takes away from the business focus. This plugin can help ease that process by demonstrating a reference implementation of these features.

Usage

Creating new emails

Emails should usually still be created using ActionMailer. However, instead of delivering the emails, you can queue the emails like so:

  Notifier.deliver_signup_notification(david) # sends the email now
  Notifier.queue_signup_notification(david) # sends the email later (has_emails kicks in)

In addition to queueing emails, you can build them directly like so:

  email_address = EmailAddress.find(123)
  email = email_address.emails.build
  email.to EmailAddress.find(456)
  email.subject = 'Hey!'
  email.body = 'Does anyone want to go out tonight?'
  email.deliver

Replying to emails

  reply = email.reply_to_all
  reply.body = "I'd love to go out!"
  reply.deliver

Forwarding emails

  forward = email.forward
  forward.body = 'Interested?'
  forward.deliver

Processing email asynchronously

In addition to delivering emails immediately, you can also queue emails so that an external application processes and delivers them (as mentioned above). This is especially useful when you want to asynchronously send e-mails so that it doesn’t block the user interface on your web application.

To process queued emails, you need an external cron job that checks and sends them like so:

  Email.with_state('queued').each do |email|
    email.deliver
  end

Testing

Before you can run any tests, the following gem must be installed:

  • plugin_test_helper

To run against a specific version of Rails:

  rake test RAILS_FRAMEWORK_ROOT=/path/to/rails

Dependencies

  • Rails 2.3 or later
  • has_messages
  • state_machine
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server