【发布时间】:2014-10-25 04:34:54
【问题描述】:
我正在尝试设置我的 rails 4 应用程序,以便它发送电子邮件。有谁知道我为什么会得到:
Net::SMTPAuthenticationError
534-5.7.9 Application-specific password required.
??????
我正在使用设计,并且刚刚设置了一个单独的“共享”邮件程序来发送电子邮件。我已经尝试按照对此类问题的其他回复中的建议访问accounts.google.com/b/0/DisplayUnlockCaptcha,但是当我重新启动服务器并尝试以用户身份发送电子邮件时,没有任何变化。
有什么想法吗?干杯!
config/environments/development.rb:
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
# Don't care if the mailer can't send.
# config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
# Gmail SMTP server setup
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:domain => "mail.google.com",
:port => 587,
:authentication => :plain,
:user_name => "myrealaddress@gmail.com",
:password => "myrealpassword",
:enable_starttls_auto => true
}
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
# false prevents mail from being sent in development environment
config.action_mailer.perform_deliveries = true
end
邮寄/分享:
class Share < ActionMailer::Base
default_url_options[:host] = "localhost:3000"
default from: "myrealaddress@gmail.com"
def profile(profile, destination)
@profile = profile
mail(to: destination, subject: "sent you stuff")
end
end
【问题讨论】:
-
我认为你的 gmail 有问题,可能是被锁定了。尝试在 gmail 上使用该帐户登录,看看会发生什么。
-
嗨!我可以正常登录。我也尝试解锁验证码,无论哪种方式都应该允许访问 10 分钟......仍然不知道为什么它不开心。任何想法如何禁用发送,以便我可以摆脱浏览器错误?
-
尝试测试一个简单的发送电子邮件功能以确保它正常工作
标签: email ruby-on-rails-4 devise actionmailer