Action :: Mailer does not deliver mail to recipients

I tried to send mail to the user when his profile is being viewed. ie When a user clicks on the display of a specific contact, the contact will be notified of the profile submission. I had no mistakes. But there is some delay when I started the mail program. It also works great in the console. But mail is not sent to the recipient.

This is what I have tried so far.

mailer.rb

class CustomerSupport < ActionMailer::Base
    def customer_support(contact) 
     mail :to => contact.email, :from => "sugukvs92@gmail.com", :subject => "profileviews"       
  end
  end

setup_mail.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "smtp.gmail.com",
   :port => 587,
   :domain => "gmail.com",
   :user_name => "sugukvs92",
   :password => "**************",
   :authentication => "plain",
   :enable_starttls_auto => true
}

controller.rb

def show
  @contact = Contact.find(params[:id])
    CustomerSupport.customer_support(@contact).deliver

end

Do I need to add any stone for its implementation?

development.log

GET "//3" 127.0.0.1 2014-07-16 10:48:07 +0530 ContactsController # HTML : { "id" = > "3" } [1m [36mContact Load (0.2ms) [0m [1mSELECT contacts. * FROM contacts WHERE contacts. id= 3 LIMIT 1 [0m customer_support/customer_support.html.erb(0.1ms)

CustomerSupport # customer_support: 11.9

Sent mail to suganya.gnanasekar@in.reportbee.com (1797.4ms)
Date: Wed, 16 Jul 2014 10:48:07 +0530
From: sugukvs92@gmail.com
To: suganya.gnanasekar@in.reportbee.com
Message-ID: <53c60b0f7e609_b993ec57901998d@ameex.mail>
Subject: customer support from Report Bee
 Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to example.com, </h1>
<p>
  You have successfully signed up to example.com,

</p>
<p>
  To login to the site, just follow this link: 
</p>
<p>Thanks for joining and have a great day!</p>
 </body>
 </html>
 Rendered contacts/show.html.erb within layouts/application (0.6ms)
Completed 200 OK in 1829ms (Views: 16.2ms | ActiveRecord: 0.2ms)
+4
1

, .

development.rb.

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

. gmail, :from. , .

+6

Source: https://habr.com/ru/post/1548442/


All Articles