无法通过开发和生产环境发送电子邮件验证链接

时间:2020-07-20 05:13:22

标签: ruby-on-rails devise sendgrid

sendgrid在开发和生产环境中未发送电子邮件验证链接。 我的environment.rb文件看起来像这样

ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:address => 'smtp.sendgrid.net',
:port => '578',
:authentication => :plain,
:enable_starttls_auto => true
}

我在development.rb文件中添加了这两行,就像这样

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options ={:host => 'http://localhost:3000'}

在production.rb文件中,我添加了这两行代码

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options ={:host => 'warm-forest-79168.herokuapp.com', 
:protocol => 'https'}

在.profile文件中,我导出了sendgrid用户名和密码

export SENDGRID_USERNAME=XXXXXXX
export SNDGRID_PASSWORD=XXXXXXXX

我在Wiki https://github.com/heartcombo/devise/wiki/How-To:-Add-:confirmable-to-Users之后关注了其余要在设计用户中添加确认的人

当我在本地注册时,邮件已发送但从未收到

Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome deepakchauhan3294@gmail.com!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation? 
 confirmation_token=GKBtUsWUJ1N3HQow9d94">Confirm my account</a></p>

在生产环境(heroku)中注册时,出现以下错误

Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password

我已经重新检查了我的用户名和密码,都仍然正确。这是抛出错误。请帮助我,我在其中停留了太长时间。

0 个答案:

没有答案