all of app's functionality works except email function. works fine , expected in development. hosted app using digitalocean's ruby on rails one-click server setup. here link instructions: https://www.digitalocean.com/community/tutorials/how-to-use-the-ruby-on-rails-one-click-application-on-digitalocean
here development.rb
rails.application.configure # settings specified here take precedence on in config/application.rb. # in development environment application's code reloaded on # every request. slows down response time perfect development # since don't have restart web server when make code changes. config.cache_classes = false # not eager load code on boot. config.eager_load = false # show full error reports , disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # don't care if mailer can't send. config.action_mailer.raise_delivery_errors = false #devise wants config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } # print deprecation notices rails logger. config.active_support.deprecation = :log # raise error on page load if there pending migrations. config.active_record.migration_error = :page_load # debug mode disables concatenation , preprocessing of assets. # option may cause significant delays in view rendering large # number of complex assets. config.assets.debug = true # asset digests allow set far-future http expiration dates on assets, # yet still able expire them through digest params. config.assets.digest = true # adds additional error checking when serving assets @ runtime. # checks improperly declared sprockets dependencies. # raises helpful error messages. config.assets.raise_runtime_errors = true # raises error missing translations # config.action_view.raise_on_missing_translations = true #action mailer config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'p3plcpnl0334.prod.phx3.secureserver.net', port: 465, domain: 'finaltouchsecurity.com', user_name: 'receipts@finaltouchsecurity.com', password: 'xxxxxxxxxx', authentication: 'plain', #enable_starttls_auto: true ssl: true } end
here production.rb
rails.application.configure # settings specified here take precedence on in config/application.rb. # code not reloaded between requests. config.cache_classes = true # eager load code on boot. eager loads of rails , # application in memory, allowing both threaded web servers # , relying on copy on write perform better. # rake tasks automatically ignore option performance. config.eager_load = true # full error reports disabled , caching turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # enable rack::cache put simple http cache in front of application # add `rack-cache` gemfile before enabling this. # large-scale production use, consider using caching reverse proxy # nginx, varnish or squid. # config.action_dispatch.rack_cache = true # disable serving static files `/public` folder default since # apache or nginx handles this. config.serve_static_files = env['rails_serve_static_files'].present? # compress javascripts , css. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # not fallback assets pipeline if precompiled asset missed. config.assets.compile = false # asset digests allow set far-future http expiration dates on assets, # yet still able expire them through digest params. config.assets.digest = true # `config.assets.precompile` , `config.assets.version` have moved config/initializers/assets.rb # specifies header server uses sending files. # config.action_dispatch.x_sendfile_header = 'x-sendfile' # apache # config.action_dispatch.x_sendfile_header = 'x-accel-redirect' # nginx # force access app on ssl, use strict-transport-security, , use secure cookies. # config.force_ssl = true # use lowest log level ensure availability of diagnostic information # when problems arise. config.log_level = :debug # prepend log lines following tags. # config.log_tags = [ :subdomain, :uuid ] # use different logger distributed setups. # config.logger = activesupport::taggedlogging.new(sysloglogger.new) # use different cache store in production. # config.cache_store = :mem_cache_store # enable serving of images, stylesheets, , javascripts asset server. # config.action_controller.asset_host = 'http://assets.example.com' # ignore bad email addresses , not raise email delivery errors. # set true , configure email server immediate delivery raise delivery errors. # config.action_mailer.raise_delivery_errors = false # enable locale fallbacks i18n (makes lookups locale fall # i18n.default_locale when translation cannot found). config.i18n.fallbacks = true # send deprecation notices registered listeners. config.active_support.deprecation = :notify # use default logging formatter pid , timestamp not suppressed. config.log_formatter = ::logger::formatter.new # not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
my controller
def create @job = job.find(session[:edit_job]) @receipt = @job.receipts.create(params.require(:receipt).permit(:email, :information)) if @receipt.valid? begin email render :js => "window.location = '/jobs/#{session[:edit_job]}/edit'" rescue @receipt.destroy flash[:error] = "error sending email!" render "layouts/fail" end else flash[:error] = "error creating receipt!" render "layouts/fail" end end def email customermailer.email_receipt(@receipt).deliver_now flash[:notice] = "email sent successfully." end
i unsure of how check server logs, positive email function throwing error because flash indicates error messaging.
config.action_mailer.smtp_settings
set in development
, not in production
, rails trying connect default, localhost:25
. need add configuration config/environments/production.rb
.
if settings same in both environments, can move config have (both smtp_settings
, delivery_method
) config/environments/development.rb
config/application.rb
- latter global configuration runs in environments. if that, you'll want set delivery_method
:test
in config/environments/test.rb
don't accidentally send mail during testing.
Comments
Post a Comment