Rails 3: no action mailer specified: from => parameters

Hi guys, I'm trying to start email on the "Contacts" page, and the letters go through perfectly, but the problem is that the "from" field does not display mine: from => "", which is inside my mail method. The same thing happens with my password recovery function, which is below. The email that is stored in the "from" field is " myusername@gmail.com " from smtp settings. Really appreciate any help with this!

I use Gmail and configure my smtp settings as follows:

config / Initializers / mailer_setup

ActionMailer::Base.smtp_settings = {
     :address              => "smtp.gmail.com",
     :port                 => 587,
     :domain               => "mydomain.com",
     :user_name            => "myusername@gmail.com",
     :password             => "mypassword",
     :authentication       => "plain",
     :enable_starttls_auto => true
     }

mailer / user _mailer.rb

   def reset_password_instructions(user)
     @user = user
     @url  = "http://localhost:3000"
     mail(:to => user.email,
          :from => "test@mydomain.com",
          :subject => "recover your password"
          )
   end
end

view / mailer / rest_password_instructions.html.erb

<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password, and you can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
+2
1

Gmail from . , SendGrid.

google "Rails gmail from field", , , , .

+2

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


All Articles