Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
ActionMailer - Sending emails from localhost?
4 Posts
ActionMailer - Sending emails from localhost?

Hi, i'm trying to use ActionMailer to send some emails from rails, but here's the thing:

My server is running on localhost, i made the perfect configuration for ActionMailer properties...But, when i'm running on localhost, should that emails are sending correctly?Or they will be send only when i deploy the page for a real server?

Thanks

Mails can also be sent from localhost, if the localhost is in network having a server you should have correct settings for domain, address and port. If your localhost is a stanalone machine you can use gmail's smtp server setting for sending mail.

Thanks, i will try again.

Jhimy: you can configure ActionMailer to perform_deliveries or not in an environment.rb file. Set it to deliver or not deliver depending on which environment you're running.

Something like this

if ENV['RAILS_ENV']!="production"

ActionMailer::Base.smtp_settings = {

 .... 

} ActionMailer::Base.perform_deliveries = true

else

ActionMailer::Base.smtp_settings = {

  .... 

} ActionMailer::Base.perform_deliveries = false

You can also set this property in the development.rb and production.rb files as follows, config.action_mailer.perform_deliveries = true or config.action_mailer.perform_deliveries = false Hope this helps!

4 Posts
Login to add your message