Chapter 12. Sending email

 

This chapter covers

  • Sending email with Action Mailer and the mail gem
  • Subscribing via email to specific events within the system
  • Connecting to a real-world email server to send emails
  • Receiving emails using Action Mailer

In the previous chapter, you implemented tagging for your application, which allows users to easily categorize and search for tickets.

In this chapter, you’ll begin to send emails to your users. When a user signs up to Ticketee, they use their email address as a way for the system to uniquely identify them. You then verify that the address is valid by sending the user a confirmation email. With a user’s validated email address, you’re able to send them updates for important events in the system, such as a ticket being updated.

Back in chapter 6, you changed a setting for the authentication engine Devise that would send a confirmation email to a new user when they signed up. To test this setting, you used a gem called email_spec, which only tested that the emails were delivered in a test environment, and not in the real world. This is how Action Mailer (the Rails component responsible for email) acts[1] during a test environment.

1 It defaults to not truly sending out the emails, but rather keeping track of them in a variable that you can access by using ActionMailer::Base.deliveries, or by using the methods found in email_spec.

12.1. Sending ticket notifications

12.2. Subscribing to updates

12.3. Real-world email

12.4. Receiving emails

12.5. Summary