gpt4 book ai didi

ruby-on-rails-4 - Net::SMTPAuthenticationError,535-5.7.8 用户名和密码不被接受

转载 作者:行者123 更新时间:2023-12-02 04:12:12 25 4
gpt4 key购买 nike

我已经查看了此问题的先前答案,但我仍然无法弄清楚我的参数出了什么问题。

我修改了我的 Gmail 帐户,使其允许安全性较低的应用程序,并使用验证码将其解锁,但它仍然不接受我的用户名和密码,即使我确信它们是正确的。

这是我的文件:

配置/环境/生产.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="264b5f4b474f4a66414b474f4a0845494b" rel="noreferrer noopener nofollow">[email protected]</a>",
:password => "mypassword",
:authentication => :login,
:enable_starttls_auto => true
}

config/initializers/smtp_settings.rb

ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mywebsite.fr",
:user_name => "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a67736f676b63664a6d676b636624696567" rel="noreferrer noopener nofollow">[email protected]</a>",
:password => 'myPassword',
:authentication => :login,
:enable_starttls_auto => true
}

我想我做错了什么,或者把一些东西放在不属于的地方。在看到这么多不同的方法后,我迷失了。

最佳答案

我是初学者,这是我第一次在 stackoverflow 上发帖,希望这对您有所帮助。如果我可以进一步帮助您,请告诉我!另外,如果您想使用 sendgrid 和 heroku,我也可以提供帮助。

因此,当涉及到我的 Gmail 身份验证设置时,我还必须允许安全性较低的应用程序,并解锁验证码。除了 Gmail 设置中的这两项更改之外,我还必须转到我的 Gmail 设置 > 转发和 POP/IMAP>,然后单击启用 IMAP。保存您的更改。这些都是我对我的 Gmail 所做的所有更改。

进行以下更改:

config/initializers/setup_mail.rb将身份验证更改为:plain

if Rails.env.development? || Rails.env.production?
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.gmail.com',
port: '587',
authentication: :plain,
user_name: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3841574d4a7d55595154785f55595154165b5755" rel="noreferrer noopener nofollow">[email protected]</a>',
password: 'yourSecureGmailPassword',
domain: 'mail.google.com',
enable_starttls_auto: true
}
end

config/environments/test.rb 主机是一个网站,因为我使用的是cloud9

config.action_mailer.default_url_options = { host: 'https://blocipedia-sunnygoo.c9users.io', port: 3000 }

config/environments/development.rb

config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: 'same as in test.rb', port: 3000 }

应用程序/模型/user.rb

devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable

应用程序/mailers/application_mailer.rb

class ApplicationMailer < ActionMailer::Base
default from: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f69084999bb6938e979b869a93d895999b" rel="noreferrer noopener nofollow">[email protected]</a>"
layout 'mailer'
end

应用程序/mailers/user_mailer.rb

class UserMailer < ApplicationMailer
default from: "sunnydgoswami@@gmail.com"

def new_user(user)
@user = user
mail(to: user.email, subject: "Welcome to Blocipedia!")
end
end

app/views/layouts/mailer.html.erb

          <html>
<body>
<%= yield %>
</body>
</html>

app/views/layouts/mailer.text.erb

<%= yield %>

app/views/user_mailer/new_user.html.erb

'<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-
equiv="Content-Type" />
</head>
<body>
<h1>Welcome, new user!</h1>
<p>
<%= @user.email %>, join us in creating a vibrant wiki
atmosphere!
</p>
<p>
You signed up using <%= @user.email %>. You will be
using this email next time to log in.
</p>
</body>
</html>'

关于ruby-on-rails-4 - Net::SMTPAuthenticationError,535-5.7.8 用户名和密码不被接受,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36037491/

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