Setting up email sends in rails app

Hi, I created a ruby on rails app on Replit and is trying to create a contact form that will email me the content of the form fields to me whenever a new user submits.

At the moment, the website seems to work but I’m not able to actually receive the email and there’s no error message in the logs. Also checked spam as well, there’s nothing there.

I’m trying to use sendgrid to send the email

I’m thinking maybe it’s the configuration file being put in the wrong environment? I have the following in production.rb. is this the right place to put it?

  ActionMailer::Base.smtp_settings = {
    user_name: 'apikey', # This is the string literal 'apikey', NOT the ID of your API key
    password: ENV['SENDGRID_API_KEY'], # This is the secret sendgrid API key which was issued during API key creation
    domain: 'evdatahub.com',
    address: 'smtp.sendgrid.net',
    port: 587,
    authentication: :plain,
    enable_starttls_auto: true
  }

Hey there! Do you think this is a replit error, or you need help with your code?

I think this might be an environment thing…but tbh not entirely sure. I’m kind of new to both coding and repl so I’m sort of learning as I go along

this is the repl if that helps https://replit.com/@YilunZhang2/evdatahub

1 Like

This is a screenshot of the message i took from the console, seems like it was successful and there’s no error code, but i didn’t get the email, which suggests that it might be an environment issue

I personally don’t have experience with ruby. @CodingCactus help?

Hi @YilunZhang2 I believe you should add config.action_mailer.perform_deliveries = true to your config/environments/development.rb file, and also its probably a good idea to set config.action_mailer.raise_delivery_error to true in development (line 40).