Skip to content

Instantly share code, notes, and snippets.

@malachaifrazier
Created November 21, 2012 03:39
Show Gist options
  • Select an option

  • Save malachaifrazier/4122873 to your computer and use it in GitHub Desktop.

Select an option

Save malachaifrazier/4122873 to your computer and use it in GitHub Desktop.
Rails 3 ActionMailer w/GMail fail
# ( Using Rail 3.2.8 )
# I have my development.rb file :
ButterApp::Application.configure do
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
# Devise
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
# Paperclip & ImageMagic
Paperclip.options[:command_path] = "/usr/bin/convert"
# change to true to allow email to be sent during development
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"
Rails.application.routes.default_url_options[:host]= 'localhost:3000'
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "[email protected]",
:password => "MYPASSWORDZ",
:authentication => "plain",
:enable_starttls_auto => true
}
end
Loading development environment (Rails 3.2.8)
1.9.3p327 :001 > UserMailer.registration_confirmation(User.first)
User Load (1.3ms) SELECT "users".* FROM "users" LIMIT 1
=> #<Mail::Message:85990530, Multipart: false, Headers: <From: [email protected]>, <To: [email protected]>, <Subject: Registered>, <Mime-Version: 1.0>, <Content-Type: text/plain>>
# My Mailer:
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def registration_confirmation(user)
@user = user
mail(:to => user.email, :subject => "Registered")
end
end
@malachaifrazier
Copy link
Author

In my Rails Console, I'll call:

UserMailer.registration_confirmation(User.first)

And get this output:

User Load (1.1ms) SELECT "users".* FROM "users" LIMIT 1
=> #<Mail::Message:100296830, Multipart: false, Headers: <To: [email protected]>, <Subject: Registered>, <Mime-Version: 1.0>, <Content-Type: text/plain>>

But nothing shows up in my mailbox...help?

@malachaifrazier
Copy link
Author

Correction...I get this here;

' User Load (1.3ms) SELECT "users".* FROM "users" LIMIT 1
=> #<Mail::Message:85990530, Multipart: false, Headers: <From: [email protected]>, <To: [email protected]>, <Subject: Registered>, <Mime-Version: 1.0>, <Content-Type: text/plain>> '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment