Art B
Art B

Reputation: 147

How to send emails with Heroku and Gmail?

I have the method in my controller home_controller.rb:

def send_letters
    if Card.created_before(Time.now).any?
      @users = User.all
      @users.each do |user|
        CardMailer.send_expired_cards(user.email).deliver_now
      end
    end
    redirect_to root_path
  end

And mailer for it card_mailer.rb:

class CardMailer < ApplicationMailer
  default from: "[email protected]"

  def send_expired_cards(email)
    @email = email
    @url = "http://flashcards.com"

    @cards = Card.created_before(Time.now)
    mail(to: @email,
         subject: "Простроченные карточки на проверку от сайта Flashcards.com")
  end
end

Everything is configured to send manual letters (i just click link "Send emails" and method send_letters from controller is executed). Works fine. But I need to send these emails every day in schedule from Heroku service.

Scheduler from Heroku is pluged in my Heroku Dashboard. What I have to write in this string enter image description here to activate send_letters method .

Upvotes: 1

Views: 590

Answers (1)

Vishnu Atrai
Vishnu Atrai

Reputation: 2368

Use one of mailer addon given in screenshot. You may find some free addon also.

enter image description here

Upvotes: 2

Related Questions