2013-04-24 226 views
0

郵寄/ development.rb如何使用SMTP服務器發送電子郵件?

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
:adress => '[email protected]', 
:port => 25, 
:authentication => :login, 
:user_name => 'myemail', 
:password => 'secret' 
} 

這裏是我的梅勒:

class UserMailer < ActionMailer::Base 
def welcome_email(name, email, subject, question) 
@recipients = email 
@from   = "[email protected]" 
headers   "Reply-to" => "[email protected]" 
@subject  = "Welcome to MyDomain" 
@sent_on  = Time.now 
@content_type = "text/html" 
#body[:username] = name 
mail(:to => email, :subject => subject, :from => '[email protected]') 
end 
end 

有此錯誤: 504 5.3.3 AUTH機制LOGIN不可

請幫幫忙, 謝謝提前。

+0

你提的問題是非常不清楚。你期望發生什麼,你會得到什麼樣的錯誤/意外結果? – 2013-04-24 09:36:58

+0

爲什麼你想要獲得專欄?你將如何渲染這些列?此外,你的問題的標題是誤導性的。 – 2013-04-24 09:40:50

+0

嘗試編輯您的問題,使其更具信息性 – 2013-04-24 09:41:08

回答

1

我用的東西沿着這些路線與Gmail交談

config.action_mailer.delivery_method = :smtp 
config.action_mailer.perform_deliveries = true 

config.action_mailer.smtp_settings = { 
:address => 'smtp.gmail.com', 
:port => 587, 
:authentication => 'plain', 
:user_name => 'myemail', 
:password => 'secret', 
:enable_starttls_auto => true, 
:domain => 'gmail.com' 
} 
相關問題