# Email section

**URL:** <https://www.ruby-forum.com/t/email-section/184901>\
**Category:** Rails\
**Created:** [March 10, 2010, 7:04am UTC](https://www.ruby-forum.com/t/email-section/184901 "2010-03-10T07:04:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 10, 2010, 7:04am UTC](https://www.ruby-forum.com/t/email-section/184901/1 "2010-03-10T07:04:13Z")

</div>

Sir , I want to implement email section in ma web application…  
so i found the method ‘server\_setting’ for it…  
Following is the method:

config.action\_mailer.server\_settings = {  
:address =\> “[smtp.gmail.com](http://smtp.gmail.com)” ,  
:port =\> 25,  
:domain =\> “[gmail.com](http://gmail.com)” ,  
:authentication =\> :login,  
:user\_name =\> “manish” ,  
:password =\> “belsare”  
}

sir but wen i restart my web server following errors are generated:

[root@localhost ksmm]# script/server  
=\> Booting WEBrick  
=\> Rails 2.3.4 application starting on [http://0.0.0.0:3000](http://0.0.0.0:3000)  
/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/gem\_dependency.rb:119:Warning:  
Gem::Dependency#version\_requirements is deprecated and will be removed  
on or after August 2010. Use #requirement  
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action\_mailer/base.rb:402:in  
`method_missing': undefined method `server\_settings=’ for  
ActionMailer::Base:Class (NoMethodError)  
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:602:in  
`send' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:602:in `initialize\_framework\_settings’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:601:in  
`each' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:601:in `initialize\_framework\_settings’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:598:in  
`each' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:598:in `initialize\_framework\_settings’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:155:in  
`process' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:in `send’  
… 7 levels…  
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:84  
from /usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’  
from script/server:3

what shud i do 2 avoid this problem…  
Is it because of the version of rails?

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 10, 2010, 10:53pm UTC](https://www.ruby-forum.com/t/email-section/184901/2 "2010-03-10T22:53:37Z")

</div>

Hi,

It was probably for old action mailer. You should use  
config.action\_mailer.smtp\_settings

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 11, 2010, 7:39am UTC](https://www.ruby-forum.com/t/email-section/184901/3 "2010-03-11T07:39:43Z")

</div>

Sir for the following suggestion it works well…

> config.action\_mailer.smtp\_settings

But wen i further implement it…  
It givs the following error:

getaddrinfo: Temporary failure in name resolution

Application Trace:

/usr/lib/ruby/1.8/net/protocol.rb:206:in `initialize' /usr/lib/ruby/1.8/net/protocol.rb:206:in`new’  
/usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open' /usr/lib/ruby/1.8/timeout.rb:62:in`timeout’  
/usr/lib/ruby/1.8/timeout.rb:93:in `timeout' /usr/lib/ruby/1.8/net/protocol.rb:206:in`old\_open’  
/usr/lib/ruby/1.8/net/smtp.rb:392:in `do_start' /usr/lib/ruby/1.8/net/smtp.rb:377:in`start’  
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action\_mailer/base.rb:684:in  
`perform_delivery_smtp' /usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:525:in` **send** ’  
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action\_mailer/base.rb:525:in  
`deliver!' /usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:397:in`method\_missing’  
/root/ksmm/app/controllers/email\_controller.rb:12:in `remind’

SIr following errors were generated.Can u please help meh regarding  
diz…  
Thanks in Advance!

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 11, 2010, 7:56am UTC](https://www.ruby-forum.com/t/email-section/184901/4 "2010-03-11T07:56:43Z")

</div>

def remind  
@title = “Mail me my login information”  
if param\_posted?(:user)  
email = params[:user][:email]  
user = User.find\_by\_email(email)  
if user  
UserMailer.deliver\_reminder(user)  
flash[:notice] = “Login information was sent.”  
redirect\_to :action =\> “index”, :controller =\> “site”  
else  
flash[:notice] = “There is no user with that email address.”  
end  
end  
end

Sir this is the code that we implemented in email\_controller for :action  
=\> “remind”

Do i need to make any corrections in diz code?

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 11, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/email-section/184901/5 "2010-03-11T22:51:44Z")

</div>

Manish,

> /root/ksmm/app/controllers/email\_controller.rb:12:in `remind’

It says there is an error on line 12. I’m guessing this is the line

```
  UserMailer.deliver_reminder(user)

```

You might want to paste the code for that method too.

Punit

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 12, 2010, 6:00pm UTC](https://www.ruby-forum.com/t/email-section/184901/6 "2010-03-12T18:00:14Z")

</div>

class EmailController \< ApplicationController

include ProfileHelper  
before\_filter :protect, :only =\> [“correspond”]

def remind  
@title = “Mail me my login information”  
if param\_posted?(:user)  
email = params[:user][:email]  
user = User.find\_by\_email(email)  
if user  
UserMailer.deliver\_reminder(user)  
flash[:notice] = “Login information was sent.”  
redirect\_to :action =\> “index”, :controller =\> “site”  
else  
flash[:notice] = “There is no user with that email address.”  
end  
end  
end

def email\_sent

```
MyMailer::deliver_mail("removed_email_address@domain.invalid")

```

end

def correspond  
user = User.find(session[:user\_id])

```
id=session[:user_id]
 Personal.find_each do |@per|
    if(@per.user_id == id) # id is user id
      @per_id = "#{@per.id}" #que_id is question_id
      break
    end
 end
 idd=@per_id
 #flash[:notice] = idd
 iddd=idd.to_i

recipient = User.find_by_user_name(params[:id])

@title = "Email: #{@per.first_name} #{@per.last_name} 

```

(#{user.user\_name}) :: Recipient: #{recipient.user\_name}"  
if param\_posted?(:message)  
@message = Message.new(params[:message])  
if @message.valid?  
UserMailer.deliver\_message(  
:user =\> user,  
:recipient =\> recipient,  
:message =\> @message,  
:user\_url =\> profile\_for(user),  
:reply\_url =\> url\_for(:action =\> “correspond”,  
:id =\> user.user\_name)  
)  
flash[:notice] = “Email sent.”  
redirect\_to profile\_for(recipient)  
end  
end  
end

end

ya diz is the code for email\_controller…  
Can u please tell me what is the problem that the email is not being  
sent?

---

<div class="post-metadata">

**Author:** ![manish\_belsare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@manish\_belsare](https://www.ruby-forum.com/u/manish_belsare)\
**Post date:** [March 12, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/email-section/184901/7 "2010-03-12T18:03:12Z")

</div>

class UserMailer \< ActionMailer::Base  
def reminder(user)  
@subject = ‘Your login information at [KnowledgeEngine.com](http://KnowledgeEngine.com)’  
@body = {}  
#Give body access to the user information.  
@body[“user”] = user  
@recipients = user.email  
@from = ‘KnowldegeEngine [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)’  
end

def message(mail)  
subject mail[:message].subject  
from ‘KnowledgeEngine [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)’  
recipients mail[:recipient].email  
body mail  
end

end

diz is the code for UserMailer…
