Topic: Not able to send mails using ruby on rails

In environment.rb below configuration details have used

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "mydomain.com",
  :port => xx,
  :domain => 'mydomain.com',
  :authentication => true,
  :user_name => "username",
  :password => "password"
}

When trying to send mail 'Mail successfully sent' message comes but not able to receive mails.

When using the same configuration details (as below) in PHP mail sending is working fine and able to receive mails.

                        $mail->Host = "mydomain.com";
            $mail->Username = "username";
            $mail->Password = "password";
            $mail->SMTP_PORT=xx;

Can any one suggest.

Last edited by shanthini (2009-06-06 06:18:46)

Re: Not able to send mails using ruby on rails

In the ActionMailer api doc there is a hint how to set the authentication parameter.

ActionMailer::Base wrote:

:authentication - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of :plain, :login, :cram_md5.

In my application I have used
:authentication => :plain
and I assume that this is the default in most mail accounts

cheers, Rainer

Re: Not able to send mails using ruby on rails

Hi, when I was trying to send mails( in production ), I'm getting errors. Is any thing wrong in below code?

ActionMailer::Base.delivery_method = "sendmail"
ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address  => "localhost",
:port  => 21,
:domain  => "mydomain.com"
}

def checkmail
        Emailer::deliver_checkmail('archanab25@gmail.com')
        return if request.xhr?   
        render :text => 'Message sent'       
end

In models/emailer.rb,

class Emailer < ActionMailer::Base
def checkmail(to_mail,sent_at = Time.now)
         @headers = {}
      @recipients = to_mail
          @from = 'Kayaka School Foundation'
          @sent_on = sent_at
      @subject = 'Result for '
      @body["name"]='archana'
   end
end
NoMethodError (undefined method `checkmail' for #<Emailer:0xb681b6e8>):

My rails version is 2.3.x & OS is linux.

Please help me some one.

Re: Not able to send mails using ruby on rails

Try to use Emailer.deliver_checkmail instead of Emailer::deliver_checkmail

cheers, rainer

Re: Not able to send mails using ruby on rails

Hi, I'm new to RoR can anybody suggest a best tutorial link to learn a complete rails application with AdminPanel, Mailing facility, Posts, etc.

I'm using Rails 3.2.1, Ruby 1.9.3p29, gem 1.8.15.

Last edited by Kuberan (2012-02-22 04:14:47)