Skip to content

Popular Searches

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

One of the most crucial tools that help non-profit fundraising software users in keeping their audience informed, enhance engagement and keep the users updated with all the latest information is Email. In the modern era of smartphones, where people access information from their fingertips, emails help users get all the insights with just a tap of the screen. So if you are a non-profit organization or a charity donation platform owner looking for an easy method of keeping your audience informed via Email, keep reading.  

One of the most popular email service providers is Gmail, and it is also one of the most vastly used tools. Hence, Rahul Patel from GammaStack working as a Ruby on Rails developer, equipped with three years of experience in the IT industry has provided a solution to demonstrate with an example, how to implement Action mailer in Rails to send out an email to the user when he creates a new post.

These are the steps that will be followed in this article:

  • Setup a mailer.
  • Create a view email template.
  • Create the appropriate controller action to send out the emails.
  • Configure the mail settings for various mailing platforms(in this case: Gmail).

This article assumes that you already have a Post model and a controller(PostsController) related to it, that will show the confirmation to the user when the Post is successfully created.

Here is something that Rahul has setup as Post controller:

Next step is to create a mailer with the following command:

rails generate mailer PostMailer

In this case, the mailer will be used for Posts. So Rahul has named it PostMailer. After running the above command we will have a PostMailer file that will inherit ApplicationMailer(Top level library for mailers in Ruby on Rails).

Next step is to open ApplicationMailer file and set a default from address there:

#app/mailers/application_mailer.rb

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Now let’s open our newly created mailer PostMailer and create a method which will be used to send email to the user.

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Now let’s create an email view file now. Make sure you name the file is the same as the method name so that it can capture the view as an email content template.

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Now that we have the emails set up, next we’ll tell the PostsController to send an email when a new Post is created.

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Last but not the least, we need to configure our Rails app to send emails via Gmail. To do so, we’ll add the following settings to our config/environments/production.rb:
Rahul has set it for production. You can change it according to you for staging or development.

Sending Emails Made Easy with Action Mailer for Rails App for Non-profit Fundraising Software Solutions

Now you just need to replace <gmail_username> and <gmail_password> with your own username and password.

We are done now, once the rails mailer and Gmail settings are properly configured, you can easily send emails from any other controllers’ action also by generating and setting up new mailers in the same way.

When non-profit fundraising software solutions and charity donation platforms use Emails to keep their users informed, it not only helps in enhancing engagement but also helps in maintaining transparency with the audience and users.

The above solution by Rahul Patel has helped several non-profit organizations and charity donation platform owners in harnessing the power of Gmail and using the same to keep their users informed and updated.

We at GammaStack provide best-in-industry and most comprehensive non-profit software solutions, charity donation platforms, donor management software, non-profit fundraising software, and team fundraising software. 

Looking for a feature-rich solution for your non-profit organization to raise more funds and give a boost to your donor list? Contact us today!

About the author:
Rahul Patel,
Ruby on Rails developer at GammaStack