I’m having a problem with ActionMailer on Rails 2.0.2.
app/config/environment.yml
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “my.server.address.com”,
:port => 25,
:domain => “my.server.domain.com”,
:authentication => :login,
:user_name => “[email protected]”,
:password => “my_password”
}
*** LOCAL GEMS ***
actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
fxri (0.3.6)
fxruby (1.6.12)
hpricot (0.6)
log4r (1.0.5)
rails (2.0.2)
rake (0.7.3)
rubygems-update (1.0.1)
sources (0.0.1)
win32-api (1.0.4)
win32-clipboard (0.4.3)
win32-dir (0.3.2)
win32-eventlog (0.4.6)
win32-file (0.5.4)
win32-file-stat (1.2.7)
win32-process (0.5.3)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.2.0)
windows-pr (0.7.2)
And here’s my output:
=> Booting WEBrick…
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:266:in load_missing_constant': uninitialized constant ActionMailer (NameError) from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:453:in
const_missing’
from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_support/dependencies.rb:465:in const_missing' from C:/InstantRails/rails_apps/rails_space/config/ environment.rb:64 from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/ initializer.rb:47:in
run’
from C:/InstantRails/rails_apps/rails_space/config/
environment.rb:13
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in gem_original_require' from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in
require’
from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_support/dependencies.rb:496:in require' ... 8 levels... from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/ server.rb:39 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in
gem_original_require’
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require’
from script/server:3
Any assistance would be greatly appreciated.
I would guess that you have this code in the wrong place:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “my.server.address.com”,
:port => 25,
:domain => “my.server.domain.com”,
:authentication => :login,
:user_name => “[email protected]”,
:password => “my_password”
}
Try moving it out of the “Rails::Initializer.run do |config|” in the
environment.rb file. Put it at the bottom of the file, outside of that
block. You’re trying to refer to ActionMailer before the Initializer has
had a chance to load it for you. By moving the config code to the
bottom of the file, or (even better) into your development.rb &
production.rb files, you won’t call ActionMailer until after it’s been
loaded.
I appreciate your reply. I moved it out of the block, and it gave me
the same error. I also moved it to my environment/development.yml file
and it still did not work. I do see what you’re saying though, that
it’s trying to call it before it’s initialized. Is there any other
place I could put it that would ensure that it gets called after it
has initialized ActionMailer?
Thanks
On Feb 29, 12:15 pm, Brent M. [email protected]
Grrr…
The only other thing I can think of is that, in Rails 2+, there’s the
following line in the environment.rb file:
config.frameworks -= [ :active_record, :active_resource,
:action_mailer ]
It’s usually commented out. If you’ve got it activated, and it contains
:action_mailer, then Rails won’t load ActionMailer at startup. Other
than that, it might a weird InstantRails issue, and I don’t have enough
experience to help you there. 
Good luck!
I’m having the same issue, trying to setup mail first time. Do you
have any solution yet ?
Here is my stacktrace,
C:/projects/Sample/config/environments/development.rb:23:in
load_environment': undefined local variable or method
smtp’ for
#Rails::Initializer:0x2b01740 (NameError)
from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
initializer.rb:206:in `load_environment’
Any help will be appreciated.
Thanks.
Hi guys,
In Rails 2.0 you should put configuration into their own specific files
in
the initializers/ directory. Create a action_mailer.rb file in
initializers/
and then specify your ActionMailer settings within. Rails 2.0 loads all
files found in the initializers/ directory when the framework
initializes.
By the way, if you are sending your mail from an smtp host other than
your
deploy machine, specify the settings as follows:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “my.server.address.com”, # => EXTERNAL SMTP HOST
:port => 25,
:domain => “my.server.domain.com”,
:authentication => :login,
:user_name => “[email protected]”,
:password => “my_password”
}
But if your deploy machine is doing the smtp work then make sure you
specify
localhost as the address, like so:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “localhost http://my.server.address.com/”, # => HERE
:port => 25,
:domain => “my.server.domain.com”,
:authentication => :login,
:user_name => “[email protected]”,
:password => “my_password”
}
Hopefully this may solve your ActionMailer woes…
Maruis Marais
Freelance Software Developer
Email: [email protected]
[email protected]
Web: http://www.exceptionz.com
Blog: http://exceptionz.wordpress.com
Tel: +64 (0) 9 815 9273 (home)
+64 (21) 736 070 (mobile)
On Mon, Mar 17, 2008 at 3:08 PM, vimal [email protected] wrote:
from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
–
Regards,
Maruis Marais
Freelance Software Developer
Email: [email protected]
Web: http://www.exceptionz.com
We(blog): http://exceptionz.wordpress.com
Tel: +64 (0) 9 815 9273 (home)
+64 (21) 736 070 (mobile)
I have put the ActionMailer settings code in the end of
config/environment.rb file. I am in Forget password option and want to
mail user’s credentials to his mail address but when i click the button,
it shows me the following error and mail is not sent:
Net::SMTPAuthenticationError in SessionsController#create
502 unimplemented (#5.5.1)
RAILS_ROOT: C:/work/2phone
Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/1.8/net/smtp.rb:577:in auth_plain' c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in
send’
c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in authenticate' c:/ruby/lib/ruby/1.8/net/smtp.rb:411:in
do_start’
c:/ruby/lib/ruby/1.8/net/smtp.rb:378:in start' c:/ruby/lib/ruby/1.8/net/smtp.rb:316:in
start’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:586:in
perform_delivery_smtp' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
send’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
deliver!' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:352:in
method_missing’
app/controllers/sessions_controller.rb:44:in forgetpassword' app/controllers/sessions_controller.rb:22:in
create’
I have put the ActionMailer settings code in the end of
config/environment.rb file. I am in Forget password option and want to
mail user’s credentials to his mail address but when i click the button,
it shows me the following error and mail is not sent:
Net::SMTPAuthenticationError in SessionsController#create
502 unimplemented (#5.5.1)
RAILS_ROOT: C:/work/2phone
Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/1.8/net/smtp.rb:577:in auth_plain' c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in
send’
c:/ruby/lib/ruby/1.8/net/smtp.rb:571:in authenticate' c:/ruby/lib/ruby/1.8/net/smtp.rb:411:in
do_start’
c:/ruby/lib/ruby/1.8/net/smtp.rb:378:in start' c:/ruby/lib/ruby/1.8/net/smtp.rb:316:in
start’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:586:in
perform_delivery_smtp' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
send’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:469:in
deliver!' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/base.rb:352:in
method_missing’
app/controllers/sessions_controller.rb:44:in forgetpassword' app/controllers/sessions_controller.rb:22:in
create’
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Shikha S. wrote:
| I have put the ActionMailer settings code in the end of
| config/environment.rb file. I am in Forget password option and want to
| mail user’s credentials to his mail address but when i click the button,
Storing passwords as plaintext is bad. Reset the password to something
you know and send out, or, better yet, generate a one-time link to send
off to the user, together with another type of authentication that was
set, like providing the answer to a user-defined question.
Email is not safe enough to send passwords, and it is incredibly lax of
you/your team to store passwords unencrypted.
Phillip G.
Twitter: twitter.com/cynicalryan
Take care to branch the right way on equality.
~ - The Elements of Programming Style (Kernighan & Plaugher)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkf+86QACgkQbtAgaoJTgL8ECwCeLILIWqNn2jvXIljhm4y4fZuw
wdIAnjMtRdAWPLocw+K2LHx5RYjUGo56
=8nPA
-----END PGP SIGNATURE-----
Phillip G. wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Storing passwords as plaintext is bad. Reset the password to something
you know and send out, or, better yet, generate a one-time link to send
Hey passwords are stored in encrypted form using
Digest::SHA1.hexdigest("–#{salt}–#{password}–")
but i want the way how i can decrypt it and also want your help in
sending a mail. i have posted the error which was there. please send me
reply of that too, thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Shikha S. wrote:
| Phillip G. wrote:
|> -----BEGIN PGP SIGNED MESSAGE-----
|> Hash: SHA1
|>
|> Storing passwords as plaintext is bad. Reset the password to something
|> you know and send out, or, better yet, generate a one-time link to send
|
| Hey passwords are stored in encrypted form using
|
| Digest::SHA1.hexdigest(“–#{salt}–#{password}–”)
A hash is one way. There is no way to recreate a hash, especially not
one that is salted.
Phillip G.
Twitter: twitter.com/cynicalryan
~ - You know you’ve been hacking too long when…
…your children do something they shouldn’t do, you tell them to stop,
they
do it just once more anyway, so you think “Well, they prefetched the
instruction and are executing it in the delay slot.”
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkf+92QACgkQbtAgaoJTgL9u6ACfVFXbf2f+H2gqfdHkuDazApgD
jqEAn27cpFDctRyIJJBZRXLRLXC4bE2R
=Yhpo
-----END PGP SIGNATURE-----
I made sure the line was commented out, as it was by default.
Thanks for your help
On Feb 29, 11:05 pm, Brent M. [email protected]
Thanks for the info… after i paste the code outside of the block, it
worked for me.