I am developing an app on Rails 4. When user signs up using devise gem, that person can receive an email. But for cases like successful checkout, the user not getting any email despite there is InvoiceMailer#checkout: processed outbound mail in 207.2ms and Sent mail to admin@example.com (4134.8ms) message in console.
Following were my code: Controller
def success_checkout
token = params[:token]
payer_id = params[:PayerID]
@invoice = Invoice.find_by_token(token)
request = Paypal::Express::Request.new(
:username => PAYPAL_CONFIG[:username],
:password => PAYPAL_CONFIG[:password],
:signature => PAYPAL_CONFIG[:signature]
)
payment_request = Paypal::Payment::Request.new(
:currency_code => @invoice.currency,
:description => "New payment for travel booking",
:quantity => 1,
:amount => @invoice.amount_cents.to_i / 100
)
response = request.checkout!(
params[:token],
params[:PayerID],
payment_request
)
gon.is_display_currency_exchange = false
@currency_symbol = get_all_currency_symbols[@invoice.currency]
if response.ack == 'Success'
@invoice.update_attributes(:payer_id => payer_id, :status => "paid")
if @invoice.is_reward_credit
current_user.reward_credit -= 5
current_user.save
end
(1..3).each do |i|
InvoiceMailer.checkout(@invoice, i).deliver_now
end
flash[:success] = "Checkouted successfully."
else
flash[:danger] = "There is an error while processing the payment."
end
end
InvoiceMailer
class InvoiceMailer < ActionMailer::Base
default from: "MySite <support@example.com>"
include ApplicationHelper
def checkout(invoice,i)
@invoice = invoice
@currency_symbols = get_all_currency_symbols
logger.info "{event=CHECKOUT_RECEIPT status=successful store=#{invoice.contact_detail.email}}"
mail(:to => invoice.contact_detail.email, :subject => "Receipt of example")
end
end
My development.rb mailer config
#For mailer configs
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: 'www.example.com'};
config.action_mailer.smtp_settings = {
:address => 'email-smtp.us-west-2.amazonaws.com',
:port => 587,
:authentication => :plain,
:user_name => 'KEY',
:password => 'SECRET',
:enable_starttls_auto => true
}
The logger message do print out in console as {event=CHECKOUT_RECEIPT status=successful store=user@example.com}. But receive no mail. Thanks!!!