Reputation: 1493
I am trying to setup email with Mandrill on development so I can test it in production. I am new to rails and having trouble figuring out if I have to configure the 'from' (sender) email in a special. All the guides online have not helped me. I have set up an account with Mandrill and configured accordingly.
development.rb Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings =
{
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => ENV[:email],
:password => "ENV[:password]"
}
end
mailer
class ContactMailer < ActionMailer::Base
default from: "[email protected]"
def contact_user(message)
@message = message
mail(to: @message.email, subject: "Contact from AJNORTON.com").deliver
end
end
Log (no email is sent, but no error is given)
Sent mail to [email protected] (459.0ms)
Date: Sat, 29 Nov 2014 06:30:36 -0500
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Contact from AJNORTON.com
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<div>
<p>
tntn
</p>
<p>
[email protected]
</p>
<p>
ntntnt
</p>
</div>
ContactMailer#contact_user: processed outbound mail in 478.3ms
Upvotes: 0
Views: 691
Reputation: 5323
try to enable TLS: put an "enable_starttls_auto: true" and an "authentication: :plain" on your ActionMailer::Base.smtp_settings
config.action_mailer.smtp_settings =
{
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => ENV[:email],
:password => ENV[:password],
:authentication => :plain,
:enable_starttls_auto => true
}
Also, your ENV[:password] is wrong. You should't put inside quotes.
WRONG:
:password => "ENV[:password]"
CORRECT:
:password => ENV[:password]
Upvotes: 1