2010-11-28 2 views
0

레일 2.3.5내 메일에 실제로 메일이 전송되지 않지만

이것은 내 지역에 있습니다.

나는 로그는 내가 내 콘솔에서 작업을 수행 할 수 있습니다 .. 외출라는 간단한 모델/뷰/컨트롤러에게

#contact.rb 

def deliver_contact 
    ContactMailer.deliver_contact(self) 
end 

#contacts_controller 

def create 
    @contact = Contact.new(params[:contact]) 

    respond_to do |wants| 
    if @contact.save 
     @contact.deliver_contact 
     #flash[:notice] = 'Contact was successfully created.' 
     wants.html { redirect_to('/thanks') } 
    else 
     wants.html { render :action => "new" } 
    end 
    end 

을 가지고 있고 그것의 외출 말한다. 그러나 실제로받은 편지함에는 아무 것도 수신되지 않습니다. 내가 뭘 놓치고 있니? 여기에 업데이트

development.rb입니다 :

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = { 
    :address => "smtp.gmail.com", 
    :port => '25', 
    :domain => "website.com", 
    :authentication => :login, 
    :user_name => "[email protected]", 
    :password => "aged-cheese" 
} 

만들기

Processing ContactsController#create (for 127.0.0.1 at 2010-11-28 16:12:49) [POST] 
    Parameters: {"commit"=>"PUNCH IT, CHEWY!", "action"=>"create", "authenticity_token"=>"3zayXGIOWeNLwb+jhx5cIxWgHqEJdv6iwj6I=", "contact"=>{"name"=>"bob marley", "message"=>"asdfasdf", "state_id"=>"Regarding an existing order", "email"=>"[email protected]"}, "controller"=>"contacts"} 
Cache miss: Spree::Config ({}) 
    Preference Load (0.3ms) SELECT * FROM "preferences" WHERE ("preferences".owner_id = 1 AND "preferences".owner_type = 'Configuration') 
    Configuration Load (0.1ms) SELECT * FROM "configurations" WHERE ("configurations"."id" = 1) 
    CACHE (0.0ms) SELECT * FROM "configurations" WHERE ("configurations"."id" = 1) 
Cache write (will save 2.65ms): Spree::Config 
    Contact Create (0.8ms) INSERT INTO "contacts" ("name", "city", "zip", "created_at", "optin", "updated_at", "state_id", "message", "email") VALUES('bob marley', NULL, NULL, '2010-11-28 21:12:49', NULL, '2010-11-28 21:12:49', 'Regarding an existing order', 'asdfasdf', '[email protected]') 
Sent mail to [email protected] 

Date: Sun, 28 Nov 2010 16:12:50 -0500 
From: [email protected] 
To: [email protected] 
Subject: HOLY [email protected] you got mail! 
Mime-Version: 1.0 
Content-Type: text/html; charset=utf-8 

<strong>You have just received a dank crispy email.</strong> 
<br /> 
<p> 
    Here are the details of the message: 
</p> 
<p> 
    <strong>Name:</strong> 
    bob marley 
</p> 
<p> 
    <strong>Email:</strong> 
    [email protected] 
</p> 

<p> 
    <strong>Subject:</strong> 
    Regarding an existing order 
</p> 

<p> 
    <strong>Message:</strong> 
    <br /> 
    asdfasdf 
</p> 
Redirected to http://localhost:3000/thanks 
Completed in 893ms (DB: 5) | 302 Found [http://localhost/contacts] 

갱신 로그인 :

gmail tls 플러그인을 사용해 보았지만 작동하지 않았습니다. development.rb에 environment.rb로 설정을 옮겨 보았습니다.

나는 spree를 사용하고 있지만 환경 또는 development.rb에/config를 넣으면 Spree의 기본값보다 우선합니다. 또는 Spree의 관리자 내에서 메일 서버를 만들 수 있으며 올바른 사양으로 메일을 보낼 수 있습니다.

+0

합니까 메일 전송 해당 시스템에서 모든 작업을? –

+0

스팸 폴더를 확인 했습니까? – bitxwise

+0

@martin, 네, 제 다른 응용 프로그램에서 사용합니다. --- @bitxwise, 그렇습니다. 아무 것도 없었습니다. – Trip

답변

0

나는이 조각을 해결 한 두 가지 항목을 발견했습니다.

  1. 저는 Spree를 사용하여 메일 설정을 내부적으로 구성해야한다는 것을 의미했습니다. Gmail 전송에서 TLS 용 플러그인을 설치하기 위해 @ lbz의 요청을 받았음을 알기 전에. 그것은 설정과 모순되게 충돌했기 때문에 제거했을 때 작동했습니다.

  2. 테스트 서버에 전송되는 이메일을 얻으려면, 당신은 또한이 라인을 주석 처리해야합니다

    # config.action_mailer.delivery_method = :test

6

개발 모드에서 응용 프로그램을 실행하는 경우 전자 메일은 전송되지 않고 기록됩니다. config\environments\development.rb에서

Rails::Initializer.run do |config| 
    ... 
    config.action_mailer.delivery_method = :sendmail # add this line 
end 
+0

또한 시스템에서 sendmail이 올바르게 구성되었는지 확인하십시오. – karmajunkie

+0

흠, 위에서 development.rb가 지금 말한 내용으로 업데이트했습니다. – Trip

+0

'create' 액션에 대한 로그를 추가 할 수 있습니까? – lbz

1

는 여전히 다음 줄이 있습니까 : 실제로 같은으로 모드 변경 config/environment.rb 개발에 이메일을 보내려면 다음 줄을들을 언급,

# Don't care if the mailer can't send 
config.action_mailer.raise_delivery_errors = false 

그렇다면, 그리고 추가 개발에서 배달을 활성화하려면 :

# To test if we can actually send mails! 
config.action_mailer.raise_delivery_errors = true # for test 
config.action_mailer.perform_deliveries = true 
+0

팁 주셔서 감사합니다. 콘솔에서'deliver_contact'를 수행 할 때 오류가없는 것처럼 보입니다. – Trip

관련 문제