Forum: Ruby on Rails Action Mailer woes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric S. (Guest)
on 2006-01-30 03:16
(Received via mailing list)
Hi gang,
Im having my first stab at ActionMailer and not having any luck. Perhaps
someone could help me out.
I generated a a mailer called ItemMailer - its purpose is to take some
information that I've already gathered in a ToDo list form and to mail
it out to the person who is nominated for the task

In environment.rb I have;
ActionMailer::Base.server_settings = {
:address => "",
:port => 25,
:authentication => :login,
:user_name => "removed_email_address@domain.invalid",
:password => "wouldntyouliketoknow"

I have a Mailer model;
class ItemMailer < ActionMailer::Base
  	def item_assignment( address, title, body )
	  # Email header info MUST be added here
	  @recipients = address
	  @from = "removed_email_address@domain.invalid"
	  @subject = title
	  @body = body
#	  breakpoint 'mailer'
	  # Email body substitutions go here


In the controller I have;
# Send the Email
@recipient = Person.find(:first, :conditions => ['id =
@email_address = @recipient.email_address
ItemMailer::create_item_assignment(@email_address, @to_dos.title,

I dont need any fancy stuff like variable substitution, just a way to
pop the recipient, subject and body into an email object. When I try to
run this I get to the breakpoint OK so at least part of the controller
code is fine. After the breakpoint nothing happens. the app just chugs
along into the subsequent redirect and no mail is sent. There is nothing
in the development log to point to the problem

Can anyone help?
Kind Regards,
Ricky Nelson (Guest)
on 2006-01-30 04:01
(Received via mailing list)
I believe your mistake is that you are trying to send form data but
you are treating it like ActiveRecord data.  It took me a couple of
hours to get my head wrapped around it too.  Try this in your

> # Send the Email
@email = ItemMailer.create_item_assignment(params
[:whatever_your_form_data_is]) #you didn't post your form so its hard
to tell what variable to use here.
render :action => 'some_action'

then in your model do the following:

> 	end
> end

You see if you're trying to send a form then the data is an array NOT
ActiveRecord.  I hope that helps.

Eric S. (Guest)
on 2006-01-30 06:47
(Received via mailing list)
Thanks for the response. I'm a step forward and another sideways
I now have;

class ItemMailer < ActionMailer::Base
   	def item_assignment( contact )
	  # Email header info MUST be added here
	  breakpoint 'mailer'
	  @recipients = contact[:address]
	  @from = "removed_email_address@domain.invalid"
	  @subject = contact[:title]
	  @body = contact[:body]

And in Controller;
def add_to_dos
@job = Job.find(params[:id])
@to_dos = params['to_do'])
@to_dos.update_attribute( 'due_on', params[:to_do][:due_on][:date] )
@to_dos.update_attribute('created_by', '1' )
   # Log the event
   @j_evt = =>, :user_id => 1,
	:event_type_id => @to_dos.to_do_type_id,
	:title => @to_dos.title, :refer_id => )

	# Send the Email
	@recipient = Person.find(:first, :conditions => ['id =
	@email_address = @recipient.email_address
	@contact = {:address =>@email_address, :title => @to_dos.title,
:body => @to_dos.body}
	@email = ItemMailer::create_item_assignment(@contact)
	flash[:notice] = 'Item was successfully created.'
	redirect_to :action => 'job_dashboard', :id => @job
Results In;

454 oops, unable to write pipe and I can't auth (#4.3.0)
Eric S. (Guest)
on 2006-01-30 07:11
(Received via mailing list)
Sorry - should have put the full trace

  Net::SMTPAuthenticationError in Job#add_to_dos

454 oops, unable to write pipe and I can't auth (#4.3.0)

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

d:/ruby/lib/ruby/1.8/net/smtp.rb:586:in `auth_login'
d:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
d:/ruby/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
d:/ruby/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
d:/ruby/lib/ruby/1.8/net/smtp.rb:378:in `start'
d:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
#{RAILS_ROOT}/app/controllers/job_controller.rb:188:in `add_to_dos'


Parameters: {"commit"=>"Save", "to_do"=>{"sub_reference"=>"",
"body"=>"see how they run", "title"=>"Blah Blah Black Sheep",
"attachment"=>"", "user_id"=>"14", "to_do_type_id"=>"5",
"due_on"=>{"date"=>"01/30/2006"}}, "id"=>"1", "todo"=>{"log_item"=>"0",
Eric S. (Guest)
on 2006-01-30 07:26
(Received via mailing list)
OK - I'm cool - still have a problem, but it is in the ISP
authentication stuff. MAny Thanks for your help.
Guest (Guest)
on 2006-06-16 14:38
Eric S. wrote:
> OK - I'm cool - still have a problem, but it is in the ISP
> authentication stuff. MAny Thanks for your help.
> Cheers,
> Eric.

the account you are using is pop3 and not the smtp, so that may be your
This topic is locked and can not be replied to.