我没有收到确认邮件
I don't get confirm mail
我对设计邮件确认有疑问。
我添加了 mailcatcher,工作正常:
Thu, 24 Sep 2015 05:49:50 +0300
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: ...@gmail.com
Message-ID: <560364ce3f3d_34372357331e9383d@gerdon-MS-7346.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Welcome ...@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=zYTXtSnJfom1oNS-o8Fy">Confirm my account</a></p>
但我的 Gmail 收不到这个。
这是我在 rails:
上的代码
/development.rb
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}
end
/production.rb
Rails.application.configure do
config.log_level = :debug
config.i18n.fallbacks = true
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "127.0.0.1"
:port => 25,
:domain => 'localhost:3000'
}
end
我在尝试设置邮件确认时将此评论用作文档:
How do I set up email confirmation with Devise?
这听起来像是一个愚蠢的问题,但您 运行 是本地主机上的 smtp 服务器吗??
要启用电子邮件发送,您需要做两件事。
在 config/environments/development.rb 中配置您的电子邮件(不确定您是否已经完成。
通过编辑 config/initializers/devise.rb 在 Devise 中配置您的电子邮件。考虑到 "from" 地址在您的日志中可见,您肯定没有这样做。
第 1 步。如果您从 gmail 帐户发送邮件,这里是设置。注意所有电子邮件设置,包括允许在开发模式下发送电子邮件和默认 url 选项。您必须更改 smtp 设置以反映您的帐户。
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Send emails in test mode
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "domain.of.sender.net",
authentication: "plain",
user_name: "your_user_name",
password: "your_password",
enable_starttls_auto: true
}
第 2 步。配置 config/initializers/devise.rb 以包含您刚刚配置用于发送的电子邮件。
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = 'ewe44lwemwle66wmew4lewwew'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = 'YOUR_EMAIL_HERE'
我对设计邮件确认有疑问。 我添加了 mailcatcher,工作正常:
Thu, 24 Sep 2015 05:49:50 +0300
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: ...@gmail.com
Message-ID: <560364ce3f3d_34372357331e9383d@gerdon-MS-7346.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Welcome ...@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=zYTXtSnJfom1oNS-o8Fy">Confirm my account</a></p>
但我的 Gmail 收不到这个。 这是我在 rails:
上的代码/development.rb
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}
end
/production.rb
Rails.application.configure do
config.log_level = :debug
config.i18n.fallbacks = true
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "127.0.0.1"
:port => 25,
:domain => 'localhost:3000'
}
end
我在尝试设置邮件确认时将此评论用作文档: How do I set up email confirmation with Devise?
这听起来像是一个愚蠢的问题,但您 运行 是本地主机上的 smtp 服务器吗??
要启用电子邮件发送,您需要做两件事。
在 config/environments/development.rb 中配置您的电子邮件(不确定您是否已经完成。
通过编辑 config/initializers/devise.rb 在 Devise 中配置您的电子邮件。考虑到 "from" 地址在您的日志中可见,您肯定没有这样做。
第 1 步。如果您从 gmail 帐户发送邮件,这里是设置。注意所有电子邮件设置,包括允许在开发模式下发送电子邮件和默认 url 选项。您必须更改 smtp 设置以反映您的帐户。
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Send emails in test mode
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "domain.of.sender.net",
authentication: "plain",
user_name: "your_user_name",
password: "your_password",
enable_starttls_auto: true
}
第 2 步。配置 config/initializers/devise.rb 以包含您刚刚配置用于发送的电子邮件。
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = 'ewe44lwemwle66wmew4lewwew'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = 'YOUR_EMAIL_HERE'