I want you to check if it is true
and send the mail, but the mail does not arrive.
reunion.rb
after_save :autorizar
def autorizar
if self.auto = true
ReunionMailer.autorizar_email(Reunion.find(self.id)).deliver
end
end
setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com", #este es el dominio
:user_name => "[email protected]",
:password => "lucas",
:authentication => "plain",
:enable_starttls_auto => true
}
reunion_mailer.rb
class ReunionMailer < ApplicationMailer
default from: '[email protected]'
def autorizar_email(reunion)
@reunion = reunion
@url = 'http://example.com/login'
mail(to: @reunion.email, subject: 'AUTORIZACION')
end
end
application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
end
authorize_email.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Bienvenido</h1>
<p>
Esto es un ejemplo de envío de correos en una aplicación de Ruby on Rails<br>
ya esta autorizando
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
Gemfile
gem 'mail'