Hi there everyone!
I am looking to add email functionality to my project, whilst
following the railsspace tutorial.
The book suggests that I add the following into the environment.rb
file:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “smtp.example.com”,
:port => 25,
:domain => “your_domain.com”,
:authentication => :login,
:user_name => “your_user_name”,
:password => “your_password”,
}
As i’m running this in production, what do I use for these settings,
as I dont have usernames, passwords etc…
Has anyone else done this yet? and if so, how does it get done in
Production?
Also…
When I added the above code, then attempted to run ruby script/
generate mailer UserMailer
i got an error:
config/environment.rb:20: uninitialized constant ActionMailer
(NameError)
looking at that line (20) - it’s this:
ActionMailer::Base.delivery_method = :smtp
As i’m still new to this, tis is a totally new area, and not sure how
to get this up and running…
Can anyone help?
Cheers
On Nov 10, 9:19 pm, RubyonRails_newbie [email protected]
wrote:
Hi there everyone!
I am looking to add email functionality to my project, whilst
following the railsspace tutorial.
The book suggests that I add the following into the environment.rb
file:
It sounds like what you’ve done is add this too early in
environment.rb, ie before rails itself is loaded. A safe place to put
this stuff is in the per-environment configuration files (ie config/
environments/production.rb) - you don’t want your development machine
sending out real emails to your users.
As i’m running this in production, what do I use for these settings,
as I dont have usernames, passwords etc…
That depends on your mail setup. If the smtp server you’re using
doesn’t require authentication then you can leave out settings related
to authentication.
Fred
Thanks for that,
I have added it to the development area and now get the following
error:
Rails 2.3.3 application starting on http://0.0.0.0:3000
/.gem/ruby/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:
400:in method_missing': undefined method
server_settings=’ for
ActionMailer::Base:Class (NoMethodError)
now i guess this is because i havent yet defined the server settings,
however:
If I’m running on development on localhost/3000 why would i need any
specific settings?
Sorry if this is a daft question, but it seems to me that this should
work…
RubyonRails_newbie wrote:
Apologies all…
seems like the issue was with '‘server_settings’.
This was deprecated as of rails1.2.1.
Yet another deprecation. It seems that’s the issue virtually every time
you post. So…
STOP FOLLOWING THE RAILSSPACE TUTORIAL! It wasn’t designed for current
versions of Rails.
This is now replaced with smtp_settings.
No errors now!
thanks Fred! You got me in the right direction!
On 10 Nov, 22:48, RubyonRails_newbie [email protected]
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Apologies all…
seems like the issue was with '‘server_settings’.
This was deprecated as of rails1.2.1.
This is now replaced with smtp_settings.
No errors now!
thanks Fred! You got me in the right direction!
On 10 Nov, 22:48, RubyonRails_newbie [email protected]
One suggestion would be to follow the recommendation at the railsspace
site (railsspace.com) which is:
Windows:
gem install rails -v 1.2.3 --include-dependencies
Mac & Linux:
$ sudo gem install rails -v 1.2.3 --include-dependencies
The book is guaranteed to work with this version of Rails, and based
on reader feedback we recommend following this route to avoid possibly
frustrating incompatibilities with the latest version of Rails.
If you want to work with examples that more closely track current
rails versions see: http://guides.rubyonrails.org/
Following the RailsSpace book with a newer release of rails only makes
sense if you are interested in seeing how the different concepts have
evolved. This approach can get really interesting if you mix in more
than one version of ruby as well (1.8.6, 1.8.7, 1.9.1, 1.9.2dev).
Just for reference, here’s a file I use (MYAPP/config/initializers/
action_mailer.rb) to enable real mail via a gmail relay. It helps me
test with real email during development, can be used with the
restful_authentication plugin.
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => “smtp.gmail.com”,
:port => “587”,
:domain => “MY_HOST_LOCALNAME”,
:authentication => :plain,
:user_name => “VALID_GMAIL_ACCOUNT”,
:password => “VALID_ACCOUNT_PASSWORD”
}
On Nov 10, 7:05 pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-