2013-04-26 1 views
0

localhost에서 이메일을 보낼 수 없습니다. 여기 내 코드가있다. 처음에는 메일러 UserMailer를 생성했습니다. enviroment.rb :Ruby On Rails.How 이메일을 보내시겠습니까?

config.action_mailer.delivery_method = :smtp 

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

우편물/user_mailer :

class UserMailer < ActionMailer::Base 

def mail(user) 
rexipients '[email protected]' 
from '[email protected]' 
subject = "Hi" 
body :user => user 
end 
end 

내 컨트롤러 : user_mailer에서

UserMailer.deliver_mail(params[:name]) 

및 템플릿/welcome_email.html.erb :

<h1>Welcome to example.com,<%= user %> </h1> 

하지만 omthing 잘못이고 나는 당신의 설정 correct.Here가의 Gmail SMTP를 사용하는 코드입니다 만들 ...

+1

나는 확실히 모르겠다. 이메일을 보낼 때보고있는 것을 게시 할 수 있습니까 (오류 메시지, 잘못된 형식의 이메일, 다른 것)? 덧붙여 말하자면, 'rexipients'는 당신이 '수령인'을 철자하는 방법이 아닙니다 ... – PinnyM

+0

나는 어떤 오류도보고 있지 않습니다 .... –

+0

그래서 당신은 무엇이 잘못됐다고 생각합니까? – PinnyM

답변

1

을 exacally 모르는 : 확인하기 위해 development.rb에서이 다음 줄을

config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.default_url_options = { :host => 'your host' } 
    config.action_mailer.delivery_method = :smtp 
    config.action_mailer.smtp_settings = { 
    :address  => 'smtp.gmail.com', 
    :port   => '587', 
    :authentication => :plain, 
    :user_name  => 'your full email addess like [email protected]', 
    :password  => 'your account password', 
    :domain   => 'your domain' 
    } 

을 쓰기 발생하는 오류가있는 경우 :

def deliver_oggymail()  
    mail(:to => "[email protected]", :subject => ="hi") 
    end 
: 당신의 우편물에서

config.action_mailer.raise_delivery_errors = true 

을 먼저 간단한 이메일을 보내려고 0

귀하의 컨트롤러에

UserMailer.deliver_oggymail().deliver 
+0

모든 설정이 올바르게되었습니다. Idon't는 전시와 기록 위에서 약간의 과실을 만난다. 하지만 여전히 작동하지 않습니다 ... –

+1

당신은 어떤 배달 오류를 볼 수 있습니까? 받은 편지함에 메일을 받았습니까? 해결할 수 없다면 오류에 대해 말해야합니다. 마지막 행을 development.rb에 추가하고 서버를 다시 시작하고 로그를 보내고 보려고 시도하십시오. – user2323194

+0

리 서 더 서버를 다시 시도하지만 여전히 로그에 오류가 표시되지 않습니다. 그리고 이메일은 보내지지 않았습니다 ... –

관련 문제