# ActionMailer Difficulties

**URL:** <https://www.ruby-forum.com/t/actionmailer-difficulties/119892>\
**Category:** Rails\
**Created:** [November 12, 2007, 12:50am UTC](https://www.ruby-forum.com/t/actionmailer-difficulties/119892 "2007-11-12T00:50:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 12, 2007, 12:50am UTC](https://www.ruby-forum.com/t/actionmailer-difficulties/119892/1 "2007-11-12T00:50:12Z")

</div>

I’m using ActionMailer in test mode (so, in the config file I have

config.action\_mailer.delivery\_method = :test

) I have my mailer set up as such…

def confirm(message, sending\_user, user)  
@subject = “You have a message from #{sending\_user.login}”  
@body[“message”] = message  
@body[“user”] = user  
@body[“sender”] = sending\_user  
@recipients = user.email  
@from = “removed\_email\_address@domain.invalid”  
@sent\_on = Time.now  
end

And my confirm page set up as follows

Dear \<%= @user.name %\>  
\<%= @sender.login %\> has sent you the following message %\>  
\<%= @message %\>

Now, if I let @user be some user and @sending\_user be some other user,  
if I work from the console with

MessageSender.deliver\_confirm(“Message!”, @sending\_user, @user)

it works, and I see the message in the hash built by the test mode.  
But if I use the following code

def send\_message  
@user = (session[:looked\_upon\_user])  
@sending\_user = User.find(session[:user\_id])  
@message = (params[:message])  
MessageSender.deliver\_confirm(@message, @sending\_user, @user)  
end

it doesn’t, even though the send message page works, with the  
following code

# Message Sent!

\<%= @sending\_user.login %\> sent the message

\<%= @message %\>

to \<%= @user.login %\> \<%= link\_to "Return", :action =\> "index" %\>

I’ve been programming with Ruby on Rails for a few months now and am  
still trying to get the hang of it. Any help would be greatly  
appreciated.
