# UserMailer Issue - Can any one help?

**URL:** <https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758>\
**Category:** Rails\
**Created:** [November 10, 2009, 10:20pm UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758 "2009-11-10T22:20:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 10, 2009, 10:20pm UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/1 "2009-11-10T22:20:18Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 10, 2009, 10:32pm UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/2 "2009-11-10T22:32:00Z")

</div>

On Nov 10, 9:19 pm, RubyonRails\_newbie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 10, 2009, 11:51pm UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/3 "2009-11-10T23:51:00Z")

</div>

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](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…

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 11, 2009, 1:05am UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/4 "2009-11-11T01:05:20Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 10, 2009, 11:56pm UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/5 "2009-11-10T23:56:17Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![RubyonRails\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@RubyonRails\_newbie](https://www.ruby-forum.com/u/RubyonRails_newbie)\
**Post date:** [November 11, 2009, 1:35am UTC](https://www.ruby-forum.com/t/usermailer-issue-can-any-one-help/178758/6 "2009-11-11T01:35:10Z")

</div>

One suggestion would be to follow the recommendation at the railsspace  
site ([railsspace.com](http://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/](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](http://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-
