Arturo Arturo - 1 year ago 120
Ruby Question

Sent emails with Action Mailer

I am trying to send an email to with Action Mailer (Ruby on Rails). The method sendactivation is correctly executed and the message "Email sent" is displayed. However, I never receive any email. Actually, the output "Test" is never printed. My webapp is hosted on Heroku Cedar-10.

class UsersController < ApplicationController
def sendactivation
render :json => {
:result => "Email sent"

class UserMailer < ActionMailer::Base
def welcome_email()
mail(to: "",
body: "Hello",
content_type: "text/html",
subject: "Already rendered!")
puts "Test"

This is the configuration I have on my config/environment/production.rb. Actually I wanted to send it with Office 365 but I suppose it is easier to debug with a Gmail account.

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: '',
port: 587,
user_name: '',
password: '########',
authentication: 'plain',
enable_starttls_auto: true }

What am I doing wrong? Is there anything I need to change on my Gmail configuration?

ANSWER: In addition to the marked answer, I needed to set the "from" address in the welcome_email method.

Answer Source

Call method deliver:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download