Forum: Ruby on Rails Recipients did not receive the mail in Rails 2.0.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Devi R. (Guest)
on 2008-11-20 11:57
Hi,

I am new to ROR and i trying to send emails using rails version 2.0.2.
But the recipients did not receive the mail i check the log file also

parameters: {"commit"=>"Send Email",
"authenticity_token"=>"184d6f1d9095962085dcd800ce0581bda32f04ae",
"action"=>"send_mail", "controller"=>"emailer", "email"=>{"name"=>"xxx",
"body"=>"Test Mail sending using Rails ", "subject"=>"TestMail",
"address"=>"removed_email_address@domain.invalid"}}
Sent mail:
 Date: Thu, 20 Nov 2008 15:07:21 +0530

From: removed_email_address@domain.invalid

To: removed_email_address@domain.invalid

Subject: TestMail

Mime-Version: 1.0

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



Name:

xxx

Message:

Test Mail sending using Rails
Redirected to http://localhost:3001/emailer
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/emailer/send_mail]

(*) And My Configuration as
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "ip",
   :port => 26,
   :user_name => "removed_email_address@domain.invalid",
   :password => "rrr",
}
ActionMailer::Base.default_content_type = "text/html"
#ActionMailer::Base.raise_delivery_errors = true

(*) In my model is
class Emailer < ActionMailer::Base
  def contact_email(email_params, sent_at = Time.now)
        @recipients = email_params[:address]
        @from = "removed_email_address@domain.invalid"
        @subject = email_params[:subject]
        @sent_on = sent_at
        @body["email_body"] = email_params[:body]
        @body["email_name"] = email_params[:name]
    end
end

(*) Controller
class EmailerController < ApplicationController
def send_mail
      Emailer.deliver_contact_email(params[:email])
      redirect_to :action => 'index'
end
def index
      render :file => 'app\views\emailer\index.html.erb'
end
end

(*) And view is "index.rhtml"
<% form_tag :action=>'send_mail' do %>
<table>
    <tr>
        <td><label for="email_name">Name:</label></td>
        <td><%= text_field "email", "name", :size => 30 %></td>
    </tr>
    <tr>
        <td><label for="email_address">Email Address:</label></td>
        <td><%= text_field "email", "address", :size => 30 %></td>
    </tr>
    <tr>
        <td><label for="email_subject">Subject:</label></td>
        <td><%= text_field "email", "subject", :size => 30 %></td>
    </tr>
    <tr>
        <td><label for="email_body">Body:</label></td>
        <td><%= text_area "email", "body", :rows => 8, :cols => 30 %></
<td>
</tr>
</table>
<%= submit_tag 'Send Email' %>
<% end -%>

(*)And one more rhtml is "contact_email.rhtml"
Name:
<%= @email_name %>
Message:
<%= @email_body %>

If any one knows Please let me know. Thanks in Advance.

Regards
Devi.R
Jeff P. (Guest)
on 2008-11-21 05:00
Devi,
What do the smtp settings in your config/environments/production.rb file
look like?  Or if you are sending from your development machine, look at
development.rb.

Mine looks like this:
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "yourdomain.com",
}


HTH,
jp



Devi Rv wrote:
> Hi,
>
> I am new to ROR and i trying to send emails using rails version 2.0.2.
> But the recipients did not receive the mail i check the log file also
>

> If any one knows Please let me know. Thanks in Advance.
>
> Regards
> Devi.R
This topic is locked and can not be replied to.