He generado un proyecto con Ruby on Rails 6 API y he configurado una cuenta de correo y generado un mailer pero no logro que se envie en correo, cabe destacar en que en consola si aparece como enviado
Este es el controlador que envia el mailer al email del usuario indicado
class PasswordResetsController < ApplicationController
before_action :set_user, only: [:edit, :update]
KEYS = [:password, :password_confirmation].freeze
def create
user = User.find_by(email: params[:email])
if user
user.generate_password_token!
UserMailer.reset_password(user).deliver_now
end
render json: :ok
end
end
Este es el mailer
class UserMailer < ApplicationMailer
def reset_password(user)
@user = user
mail(to: @user.email, subject: 'Reestablecer contraseña' )
end
end
Esta es la vista
Hi <%= @user.full_name %>,
You have requested to reset your password.
Please follow this link:
<%= "http://localhost:8080/#/password_resets/#{@user.reset_password_token}" %>
Reset password URL is valid within 24 hours.
Have a nice day!
Asi mi archivo config/enviroments/development.rb en el apartado de smtp
config.action_mailer.perform_caching = false
# Mailer configuration
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.live.com",
:port => 25,
:user_name => "[email protected]", # the email of the account to send emails
:password => "****", # the password of the account to send emails
:authentication => "plain",
:enable_starttls_auto => true
}
y finalmente mi app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]
layout 'mailer'
end
Esta es mi salida en consola pero el email no llega a la cuenta configurada cabe señalar que [email protected] es solo como referencia y la cuenta que he configurado es una cuenta personal
> UserMailer#reset_password: processed outbound mail in 5.9ms Delivered
> mail [email protected] (2005.5ms)
> Date: Mon, 01 Jun 2020 23:38:37 -0500 From: [email protected] To:
> [email protected] Message-ID:
> <[email protected]> Subject:
> =?UTF-8?Q?Reestablecer_contrase=C3=B1a?= Mime-Version: 1.0 Content-Type: multipart/alternative;
> boundary="--==_mimepart_5ed5d7cd9bc5e_168444a749c551dc";
> charset=UTF-8 Content-Transfer-Encoding: 7bit
>
>
> ----==_mimepart_5ed5d7cd9bc5e_168444a749c551dc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit
>
> Hi ,
>
> You have requested to reset your password. Please follow this link:
> http://localhost:8080/#/password_resets/**************** Reset
> password URL is valid within 24 hours.
>
> Have a nice day!
Estoy tratando de configurar una cuenta personal ¿Me podrian orientar sobre como configurar la cuenta? Gracias