gpt4 book ai didi

email - 网络::SMTPAuthenticationError

转载 作者:行者123 更新时间:2023-12-01 23:11:30 26 4
gpt4 key购买 nike

我正在尝试设置我的 rails 4 应用程序,以便它发送电子邮件。有谁知道我为什么会得到:

Net::SMTPAuthenticationError
534-5.7.9 Application-specific password required.

??????

我正在使用设计并且刚刚设置了一个单独的“共享”邮件程序来发送电子邮件。我已经尝试按照其他对此类问题的回答中的建议访问accounts.google.com/b/0/DisplayUnlockCaptcha,但是当我重新启动服务器并尝试以用户身份发送电子邮件时没有任何变化。

有任何想法吗?干杯!

配置/环境/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 的新应用密码 - https://security.google.com/settings/security/apppasswords .

生成新密码时选择 MailSelect App设置和 Other(Custom name)Select Device环境。

获得新密码后,使用 Google 为您生成的随机字符串更新您的邮件程序配置,您应该已设置好。

关于email - 网络::SMTPAuthenticationError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25597507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com