2011-09-21 2 views
2

다음 문제 : 레일을 통해 HTML 메일을 보내려고 할 때마다 콘텐츠가 첨부 된 빈 이메일로 googlemail-adress에 도착합니다.레일을 통해 전송 된 HTML 이메일이 첨부 파일로 도착했습니다.

내가 여기서 잘못하고있는 것이 확실하지 않습니다.

설정은 다음과 같이

/app/mailers/testmail.rb 
class Testmail < ActionMailer::Base 
    default :from => "[email protected]" 
    default_url_options[:host] = '10.10.8.1' 

    def email 
    subject 'Willkommen!' 
    recipients '[email protected]' 
    from '[email protected]' 
    sent_on Time.now 
    end 
end 

/app/views/testmail/email.html.erb 
<p>Dies ist eine <strong>Testmail!</strong></p> 

/app/views/testmail/email.text.erb 
Dies ist eine Test-Email! 

이 내 Google 메일-계정에 도착 무엇 :

inbox

첫 번째 이메일는 html.erb 및 텍스트와 모습입니다 .erb 활성, 두 번째는 text.erb 만 사용합니다. 실제 메일러가 다른 서버에 있기 때문에 postfix를 다시 작성하기 때문에 "root"라는 사용자 이름을 무시합니다. (레일 서버의 메일은 내 설정이 아닌 메일 서버로 전송됩니다.)

Delivered-To: [email protected] 
Received: by 10.101.108.3 with SMTP id k3cs279048anm; 
    Wed, 21 Sep 2011 04:24:29 -0700 (PDT) 
Received: by 10.204.134.8 with SMTP id h8mr508445bkt.11.1316604268267; 
    Wed, 21 Sep 2011 04:24:28 -0700 (PDT) 
Return-Path: <[email protected]_server> 
Received: from our_server (our_server. [100.0.0.0]) 
    by mx.google.com with ESMTP id i7si2877863bke.151.2011.09.21.04.24.27; 
    Wed, 21 Sep 2011 04:24:28 -0700 (PDT) 
Received-SPF: neutral (google.com: 100.0.0.0 is neither permitted nor denied by best guess record for domain of [email protected]_server) client-ip=100.0.0.0; 
Authentication-Results: mx.google.com; spf=neutral (google.com: 100.0.0.0 is neither permitted nor denied by best guess record for domain of [email protected]_server) [email protected]_server 
Received: from zero (our_server [100.0.0.1]) 
by our_server (Postfix) with SMTP id 4251724B65 
for <[email protected]>; Wed, 21 Sep 2011 13:24:26 +0200 (CEST) 
Received: by zero (sSMTP sendmail emulation); Wed, 21 Sep 2011 13:24:26 +0200 
From: "root" <[email protected]_server> 
Date: Wed, 21 Sep 2011 13:24:25 +0200 
To: [email protected] 
Message-ID: <4e79c96a2ed6b_2ba53f7fe8[email protected]_router.mail> 
Subject: Willkommen! 
Mime-Version: 1.0 
Content-Type: multipart/alternative 
Content-Transfer-Encoding: 7bit 

----==_mimepart_4e79c96a1adc0_2ba53f7fe85ced90437f9 
Date: Wed, 21 Sep 2011 13:24:26 +0200 
Mime-Version: 1.0 
Content-Type: text/plain; 
charset=UTF-8 
Content-Transfer-Encoding: 7bit 
Content-Disposition: inline 
Content-ID: <[email protected]_router.mail> 

Dies ist eine Test-Email! 

----==_mimepart_4e79c96a1adc0_2ba53f7fe85ced90437f9 
Date: Wed, 21 Sep 2011 13:24:26 +0200 
Mime-Version: 1.0 
Content-Type: text/html; 
charset=UTF-8 
Content-Transfer-Encoding: 7bit 
Content-Disposition: inline 
Content-ID: <[email protected]_router.mail> 

<p>Dies ist eine <strong>Testmail!</strong></p> 


----==_mimepart_4e79c96a1adc0_2ba53f7fe85ced90437f9-- 

답변

1

좋아는 답을 발견했다. 그러나

mail(:to => '[email protected]') 

올바른 경계를 설정하고 설정합니다.

3

망가 루비이나 레일에 대해 아무것도 알고 있지만 나는 MIME에 대해 조금 알고 : 그리고 여기에 첫 번째 이메일에서 원시 데이터입니다. 귀하의 최상위 Content-Type 헤더는 있어야한다 : 경계이 켜지지을 포함하지 않는 이메일을 조립 위의 버전 :

Content-Type: multipart/alternative;boundary="--==_mimepart_4e79c96a1adc0_2ba53f7fe85ced90437f9" 
+0

글쎄, 나는이 버그 보고서를 발견했다 : https://rails.lighthouseapp.com/projects/8994/tickets/6657 그러나 버그에 대한 결론을 찾지 못했다 ... – Rhywden

+0

후손을 위해 위의 등대 티켓 https://github.com/rails/rails/issues/985로 마이 그 레이션되고 닫히고 @Rhywden에 의해 https://github.com/rails/rails/pull/3090에 의해 다시 열렸으며 이는 동일한 해상도로 마감되었습니다. Rhywden의 해결책으로 : Rails 3.2에서 제거 된 이전 API를 사용하지 마십시오. – Yogh

관련 문제