gpt4 book ai didi

ruby-on-rails - POPAuthenticationError - 从 Gmail 帐户轮询时出现 Mailman 错误

转载 作者:数据小太阳 更新时间:2023-10-29 07:31:42 25 4
gpt4 key购买 nike

我正在尝试启用我的 Rails 应用程序以接收来自 Gmail 帐户的电子邮件。我关注这个截屏视频:Receiving Email with Mailman .

我尝试对来 self 的 Gmail 帐户的电子邮件进行轮询,以便每次有人发送电子邮件时,我的应用程序都会收到该消息,然后相应地使用该消息更新数据库。

但是当我尝试运行“script/mailman_serve”来启动服务器和轮询时,我收到如下错误:

olins-MacBook-Pro:rentlord Ryzal$ script/mailman_server
I, [2016-02-26T02:07:58.104774 #23700] INFO -- : Mailman v0.7.3 started
I, [2016-02-26T02:07:58.105083 #23700] INFO -- : Rails root found in ., requiring environment...
/Users/Ryzal/Desktop/Sites/rentlord/config/application.rb:59: warning: already initialized constant OpenSSL::SSL::VERIFY_PEER
I, [2016-02-26T02:08:07.225640 #23700] INFO -- : POP3 receiver enabled (@pop.gmail.com).
I, [2016-02-26T02:08:07.266177 #23700] INFO -- : Polling enabled. Checking every 60 seconds.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:1005:in `check_response_auth': -ERR USER _who_? k19mb6670915wjq (Net::POPAuthenticationError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:905:in `block in auth'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:1012:in `critical'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:904:in `auth'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:566:in `do_start'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/pop.rb:536:in `start'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/receiver/pop3.rb:36:in `connect'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/application.rb:139:in `block in polling_loop'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/application.rb:137:in `loop'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/application.rb:137:in `polling_loop'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/application.rb:87:in `run'
from /Library/Ruby/Gems/2.0.0/gems/mailman-0.7.3/lib/mailman/application.rb:15:in `run'
from script/mailman_server:25:in `<main>'

这是我的 mailman_server 文件:

#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"

#Mailman.config.logger = Logger.new("log/mailman.log")

Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: ENV["xxxxxx@gmail.com"],
password: ENV["xxxxxx"]
}

Mailman::Application.run do
default do
begin
Post.receive_mail(message)
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end

有人能帮忙吗?谢谢!

###########################更新################ ##########

我的 gmail 帐户也启用了 POP 设置,但仍然出现同样的错误。这是我的 POP 设置:

enter image description here

最佳答案

我只能在一种情况下重现错误。如果我有 username 空白。

如果您可以使用此代码进行调查。把它放在项目之外的任何地方,确保安装了 mailman gem 并运行文件两次。一旦硬编码用户名,第二次将其保留为 nil:

#!/usr/bin/env ruby
require "mailman"

username = ''
### OR ###
username = 'myownaddress@gmail.com'

puts "Using username='#{username}'..."
Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: username,
password: 'password'
}
Mailman::Application.run do
default do
begin
puts message
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end

使用空白用户名

Using username=''...
I, [2016-03-02T00:01:44.059312 #16088] INFO -- : Mailman v0.7.3 started
I, [2016-03-02T00:01:44.059400 #16088] INFO -- : POP3 receiver enabled (@pop.gmail.com).
I, [2016-03-02T00:01:44.070004 #16088] INFO -- : Polling enabled. Checking every 60 seconds.
/usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/net/pop.rb:1005:in
`check_response_auth': -ERR USER _who_? z184mb105814233wlc (Net::POPAuthenticationError)

使用正确的电子邮件。

Using username='myownaddress@gmail.com'...

I, [2016-03-02T00:05:35.715465 #16178] INFO -- : Mailman v0.7.3 started
I, [2016-03-02T00:05:35.715540 #16178] INFO -- : POP3 receiver enabled (myownaddress@gmail.com@pop.gmail.com).
I, [2016-03-02T00:05:35.726853 #16178] INFO -- : Polling enabled. Checking every 60 seconds.
I, [2016-03-02T00:06:38.281546 #16178] INFO -- : Got new message from 'myownaddress@gmail.com' with subject 'http://stackoverflow.com/questions/35642212/popauthenticationerror-mailman-error-when-polling-from-gmail-account'.
Return-Path: <myownaddress@gmail.com>
Received: by 10.79.115.146 with SMTP id y28csa1793673ivf; Tue, 01 Mar 2016 15:06:05 -0800
Received: from mail-lf0-x22f.google.com (mail-lf0-x22f.google.com. [2a00:1450:4010:c07::22f]) by mx.google.com with ESMTPS id jm5dsi1257241lbc.1.2016.03.01.15.06.05 for
(...)
X-Mailer: Apple Mail (2.3124)

http://stackoverflow.com/questions/35642212/popauthenticationerror-mailma=
n-error-when-polling-from-gmail-account=

关于ruby-on-rails - POPAuthenticationError - 从 Gmail 帐户轮询时出现 Mailman 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35642212/

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