2013-03-11 35 views
0

即时通讯尝试使用小马为我的红宝石网站实现一个简单的表单,并且我一直收到错误“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

代码请参见下面的工作代码。只用我的Gmail测试了这一点。

Pony.mail(:to => '[email protected]', :via => :smtp, :via_options => 
{ 
    :address => 'smtp.gmail.com',      
    :port => '587', 
    :enable_starttls_auto => true, 
    :user_name => 'your[email protected]', 
    :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让我知道如果您需要进一步的帮助!

+0

嗨,我已经实现了你说的,但现在我得到的错误:是必需的 – 2013-03-16 18:31:54

+0

app/models/inquiry.rb:29:在'deliver' app/controllers/inquiries_controller.rb:9:在'create ' – 2013-03-16 18:32:41

+0

def递送 除非有效,否则返回false? Pony.mail({ :从=>%( “#{名称}” <#{email}>) :REPLY_TO =>电子邮件, :受试者=> “网站查询”, :体=>消息, :HTML_BODY = > simple_format(消息) }) 端 – 2013-03-16 18:33:14