我想使用Pony邮件从我的ruby脚本发送电子邮件。当我为gmail smtp设置它时它工作正常。当我将其设置为使用我们的ISP的SMPT时,我收到此错误。
iiNet代表告诉我,不需要身份验证。当我使用mail命令从命令行发送电子邮件时,它运行良好。或者甚至在使用telnet mail.iinet.com.au 25
发送电子邮件时,无需进行身份验证。
/usr/lib64/ruby/1.8/net/smtp.rb:777:in check_auth_args': SMTP-AUTH requested but missing secret phrase (ArgumentError)
用于设置
Pony.mail(:to => 'radek@edume.com.au',
:from => 'radek@edu.com.au',
:subject => 'overnight testing results',
:body => results,
:via => :smtp,
:via_options => {
#:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
:address => 'mail.iinet.com.au',
:port => '25',
#:enable_starttls_auto => true,
#:user_name => 'qwer@mail.iinet.com.au',
#:password => '1234',
:authentication => :plain, # :plain, :login, :cram_md5, no auth by default
:domain => "localhost.localdomain" # the HELO domain provided by the client to the server
}
)
如果我使用以下命令telnet mail.iinet.com.au 25
,则会发送和接收电子邮件。无需身份验证。
mail from: from@address
rcpt to: to@address
data
from: from@address
to: to@address
subject: subject line
message body
.
答案 0 :(得分:5)
您正在指定要执行身份验证。删除显示:authentication => :plain
答案 1 :(得分:3)
这对我来说就像一个魅力:
require 'pony'
Pony.mail(
:to => 'xxx',
:from => 'xxx',
:subject => 'test',
:body => "test",
:via => :smtp,
:via_options => {
:address => 'xxx',
:port => '25',
}
)
显然你需要用实际值替换这些“xxx”
答案 2 :(得分:2)
我向ponyrb小组发了一个问题,解决方法是使用enable_starttls_auto => false
所以我的最终工作代码是
Pony.mail(
:to => 'radek@edu.com.au',
:from => 'radek@edu.com.au',
:subject => 'test',
:body => "test pony",
:via => :smtp,
:via_options => {
:address => 'mail.iinet.com.au',
:port => '25',
:enable_starttls_auto => false
}
)