Ruby Forum Ruby on Rails > Actionmailer cant sent the mail

Posted by Saurav Chakraborty (prionko)
on 17.04.2008 11:55
Hi everybody,
Im facing problems in sending mail using actionmailer. Im trying to do a
simple stuff where user types in his message and the receiptent email
address, the n that message should be received by the receiptent. I have
checked the development.log file, but there I havent noticed any error,
the workflow of the program is fine, but at the end of the day, the
receiptent is not receiving the mail

Below is the controller file:

class EmailerController < ApplicationController
   def sendmail
      recipient = params[:reciptent]
      subject = params[:subject]
      message = params[:message]
      Emailer.deliver_contact(recipient, subject, message)
      return if request.xhr?
      render :text => 'Message sent successfully'
  end


thiis is the emailer class:

class Emailer < ActionMailer::Base
  def contact(recipient, subject, message, sent_at = Time.now)
      @subject = subject
      @recipients = recipient
      @from = '<webmaster@triumphindia.com>'
      @sent_on = sent_at
      body["title"] = 'This is title'
      body["email"] = 'webmaster@triumphindia.com'
      body["message"] = message
      @content_type = "text/html"

      @headers['Reply-To'] = "'Webmaster' <webmaster@triumphindia.com>"
   end
end


This the settings that I have put in environment.rb file

ActionMailer::Base.raise_delivery_errors = true;
ActionMailer::Base.delivery_method = :smtp;


ActionMailer::Base.smtp_settings = {
:address => "smtp.bizmail.yahoo.com",
:port => 25,
:domain => "bizmail.yahoo.com",
:authentication => :plain,
:user_name => "webmaster@triumphindia.com",
:password => "somepassword"
}

and this is the setting is development.rb file

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp


this is output is my development log file


Processing EmailerController#sendmail (for 127.0.0.1 at 2008-04-16
17:11:41) [POST]
  Session ID:
BAh7BzoMY3NyZl9pZCIlZjZiYjY5NmMzZTM1YzUzZTRjMDY4ZWQ4MjU2NzJi%0ANWQiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%0Ac2h7AAY6CkB1c2VkewA%3D--ff14f980e27ff9a4a3edfb58c9afd2b1375d0587
  Parameters: {"commit"=>"Send",
"authenticity_token"=>"7c49f8693944b6af67e8ed12b38de4b6fa7db513",
"action"=>"sendmail", "controller"=>"emailer",
"email"=>{"message"=>"klfdglkdfj", "recipient"=>"<prionko@gmail.com>",
"subject"=>"HIiii"}}
Sent mail:
Date: Wed, 16 Apr 2008 17:11:41 +0530

From: webmaster@triumphindia.com

Reply-To: 'Saurav' <webmaster@triumphindia.com>

Subject: Hi

Mime-Version: 1.0

Content-Type: text/html; charset=utf-8



Hi!

You are having one email message from webmaster@triumphindia.com with a
tilte

This is title
and following is the message:


Thanks
Completed in 3.75000 (0 reqs/sec) | Rendering: 0.00000 (0%) | DB:
0.00000 (0%) | 200 OK [http://localhost/emailer/sendmail]

-----------------------------------------------


Please guys help me out ....


Thanks
-Saurav
Posted by Frederick Cheung (Guest)
on 17.04.2008 12:15
(Received via mailing list)
On 17 Apr 2008, at 10:55, Saurav Chakraborty wrote:

> receiptent is not receiving the mail
>
> Below is the controller file:
>
> class EmailerController < ApplicationController
>   def sendmail
>      recipient = params[:reciptent]

You've got a typo, and so you're not setting the recipient (notice in
the log how it doesn't say who the email is sent to )

Fred
Posted by Saurav Chakraborty (prionko)
on 17.04.2008 13:14
Thanx a lot for the help....I dont know how I missed that


Frederick Cheung wrote:
> On 17 Apr 2008, at 10:55, Saurav Chakraborty wrote:
> 
>> receiptent is not receiving the mail
>>
>> Below is the controller file:
>>
>> class EmailerController < ApplicationController
>>   def sendmail
>>      recipient = params[:reciptent]
> 
> You've got a typo, and so you're not setting the recipient (notice in
> the log how it doesn't say who the email is sent to )
> 
> Fred