简体   繁体   中英

Sending mail for devise

I am trying to send mail through sendgrid from my rails app. I have setup sendgrid previously. I was able to send and receive mail in the development and the production, through heroku. Everything worked for a day. I came back a couple of days later and nothing worked.

There are no errors. In dev it says the mail is sent but the email doesn't send and same for production.

Here is my setup:

development.rb

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

production.rb

config.action_mailer.default_url_options = { host: 'herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'herokuapp.com' 
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"

setup_mail.rb

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
    address:                'smtp.sendgrid.net',
    port:                   '587',
    :authentication         => :plain,
    user_name:              'user',
    password:               'pass',
    domain:                 'herokuapp.com',
    enable_starttls_auto: true
}

I have tried resetting my pass to sendgrid and removing then re-adding it but then I run into an error saying "user banned" and I am unable to re add it.

I have also tried switching to postmark with similar results where the mail is never received but is sent.

You should check on Sendgrid if they are receiving your email requests.

From the documentation :

Search for the email in Email Activity. If we successfully delivered the message you will see a delivered event with the time of delivery. If you do not see the email come up, you can click on search options and make sure processed and deferred are checked. A processed event indicates that we actually got the request from you. Deferred events show if there are issues or delays with the receiving server accepting the message.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM