我试图使用pony为我的ruby网站实现一个简单的表单,我不断收到错误'535-5.7.1用户名和密码不被接受。我在正确的字段中输入了我自己的gmail用户名和密码。
pony.rb中的代码
Pony.options = {
:to => 'myusername',
:via => :smtp,:
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'myusername',
:password => 'mypassword',
:authentication => :plain, # :plain, :login, :cram_md5, no auth by default
:domain => "localhost.localdomain" # the HELO domain provided by the client to the server
}
}
答案 0 :(得分:0)
请参阅下面的WORKING代码。刚用我的gmail测试了这个。
Pony.mail(:to => 'someone@acme.com', :via => :smtp, :via_options =>
{
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'yourgmail@gmail.com',
:password => 'yourpass',
:authentication => :plain,
:domain => "HELO",
},
:subject => 'Your Subject goes here', :body => "bla bla bla or #{$body}",
:attachments => {"yourfile.txt" => File.binread("c:/ruby193/bin/yourfile.txt")
}
)
祝你好运Arvid让我知道你是否需要进一步的帮助!