2013-03-11 109 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