small medium large xlarge

15 Sep 2009, 15:51
Barry Mccall (4 posts)

Hello Everyone:

using Instant rails and I am trying to send an email in rails locally through the virtual apache server that instant rails starts up for me. I have not been successful here is some of the code.


ActionMailer::Base.delivery_method = :sendmail 
  #| :sendmail | :test
  ActionMailer::Base.smtp_settings = 
   :address => 'localhost',
   :port => 25,
   :domain => "",
   #:authentication => :plain,
   #:user_name => "username",
   #:password => "password",

ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.perform_deliveries = true


<h1>Send Email</h1>
<% form_tag :action => 'sendmail' do %>

	<p><label for="emailer_subject">Subject</label>:
	<%= text_field 'emailer', 'subject' %></p>
	<p><label for="emailer_recipient">Recipient</label>:
	<%= text_field 'emailer', 'recipient' %></p>
	<p><label for="emailer_message">Message</label><br/>
	<%= text_field 'emailer', 'message' %></p>
	<%= submit_tag "Send" %>
<% end %>


def sendmail
      email = params[:emailer]        #<= this does work I can get the object but I dont know how to get the info out of it
      message = params[:message]      #this code is not working either the text message isnt shouwing up
      subject = params[:subject]      #not working
      recipient = params[:recipient]  #not working
      email = Emailer.create_comments(recipient, subject, message)
      return if request.xhr?
	  flash[:notice] =  params[:message]     #this code is not working either the text message isnt showing up
	  redirect_to(:action => "comments" ) 



  def send(recipient, subject, message )
      @subject = subject
      @recipients = recipient
      @from = ''
      @sent_on =
	  @body["title"] = 'Comments'
  	  @body["email"] = ''
   	  @body["message"] = message
      @headers = {}


email to <%= @recipient %> with a title 

<%= @title %>
and following is the message:
<%= @message %>


To put it short it is not working I got most of this from a tutorial online: I chose to do this because I had fairly different needs than the example in the book (I dont have any orders to confirm I just want to send an email.) Can someone shed some light on this for me?


03 Dec 2009, 00:26
David Wilbur (50 posts)


ActionMailer::Base.smtp_settings = 
   :address => 'localhost',
   :port => 25,
   :domain => "",
   #:authentication => :plain,
   #:user_name => "username",
   #:password => "password",


is only meaningful to smtp and should be taken out. the working environment.rb that i have for sendmail only has the line:

config.action_mailer.delivery_method = :sendmail

and nothing else relative to action_mailer.

You must be logged in to comment