Skip to content

Commit

Permalink
fix: 🐛 Fix email delivery system
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanBiego committed Feb 23, 2024
1 parent 25fa378 commit a65f8a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/leads_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
class LeadsController < ApplicationController
def create
@lead = Lead.create(name: params[:name], email: params[:email])

if @lead.save
# LeadMailer.welcome_email(@lead, I18n.locale).deliver_now
flash[:success] = t('leads.create.success')
begin
LeadMailer.welcome_email(@lead, I18n.locale).deliver_now
rescue StandardError => e
Rails.logger.error("Error delivering email: #{e.message}")
end
else
flash[:alert] = t('leads.create.alert')
end

redirect_to :root
end
end
5 changes: 5 additions & 0 deletions env.exemple
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# To make the email work, put the variables provided via email and rename this file to .env

EMAIL=''
PASSWORD=''
SENDGRID_API_KEY=''

0 comments on commit a65f8a2

Please sign in to comment.