I've spent the last 4 hours just trying different things to figure out why the emails and errors i get on heroku are happening. Im very new to Rails this is my second app, so please dumb it down and talk to me like a small child, lol
http://dev-match-matt-napper.herokuapp.com/contacts/new This is my heroku link and when you click submit it says something went wrong. I am following the simpleCodeCast on udemy videos, no response from him yet.
https://github.com/Mnapper3/simpleCodeCasts_saas this is my git hub the files (master) i used were:
app/controller/contacts_controller
app/mailers/contact_mailer
app/models/contact
app/contact_mailer/contact_email.html
app/views/contacts/new.html
really hope i have given you enough info to help me, or maybe you could put in how you create form emailers? or link a video
PS im using cloud9 & if you clone this app you need to :
bundle install
bundle update
rake db:migrate
then you'll be able to preview it.
Please help!!!
-Matt Napper
You need to add mailer configuration in /config/environments/production.rb as heroku by default runs on production mode.
Add this in your /config/environments/production.rb
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: Rails.application.secrets.domain_name,
authentication: "plain",
enable_starttls_auto: true,
user_name: Rails.application.secrets.email_provider_username,
password: Rails.application.secrets.email_provider_password
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
Then in /config/secrets.yml add the following in production block like,
production:
domain_name: <%= ENV["DOMAIN_NAME"] %>
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
Finally, you must add these 3 environment variables on your heroku app. To add them, go to your heroku app settings page, I'm assuming it should be https://dashboard.heroku.com/apps/dev-match-matt-napper/settings
There you'll see a Reveal Config Vars button, click on that and add Key as your environment variable and value as it's value. For example:
Key is: GMAIL_USERNAME
Value is: Your gmail email address
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.