2

RoR 프로젝트에 이메일 본문을 표시하려고합니다.ruby ​​mailman이 이메일 본문에서 헤더를 제거합니다.

class IncomingMail 
    def initialize(message, params) 
    if person = Person.find_by_email(message.from) 
     changeMessage = Message.where({person_id: person.id}) 

     #message = message.subject.force_encoding("UTF-8") 

     message = message.body.encoded 

     changeMessage.first.text = message 
     changeMessage.first.backInMinutes = 0 
     changeMessage.first.showText = 1 
     changeMessage.first.doNotDisturb = 0 
     changeMessage.first.save 
    end 
    end 

그러나 나는 또한 내가 헤더를 제거하는 방법 이메일 헤더

> --e89a8ff1c0465030f204c082e054 Date: Mon, 21 May 2012 04:45:12 +0200 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 
> Content-Transfer-Encoding: 7bit Content-ID: 
> <[email protected]> Text of the mail 

를 얻을? 이 아니라 몸이

message = message.subject.force_encoding("UTF-8") 

같은 작품 주제와

.

+0

ActiveMailer가 자동으로 UTF-8의 제목과 본문을 인코딩 도움이되기를 바랍니다했다. 따라서 사용자 정의 인코딩을 할 필요가 없습니다. 그리고 헤더를 어디에서 얻을 수 있는지 설명해 주시겠습니까? 이메일에는 항상 from, to, subject 필드가있는 헤더가 있습니다. – Salil

+0

그 생각은 .......-- e89a8ff1c0465030f204c082e054 날짜 : 2012 년 5 월 21 일 월요일 04:45:12 +0200 Mime-Version : 1.0 콘텐츠 유형 : text/plain; charset = ISO-8859-1 > Content-Transfer-Encoding : 7bit Content-ID : ><[email protected]> ....... 다음 메일의 텍스트를 계속 ....하지만 단지 텍스트가 아니라 전에 생각하고 싶습니다 – user1402147

+0

문제는 여전히 존재합니다. 다른 이메일을 표시하고 싶습니다. 그 머리글로는 깨끗한 텍스트 만 채워서는 안됩니다. – user1402147

답변

7

나는 해결책을 발견했다 !!!

변화 :

message = message.body.encoded 

에 :

멀리 모든 헤더 세부 사항을 인하하고 나에게 전자 메일의 텍스트 만 제공
message = message.text_part.body.decoded 

.

그것은 오랜 시간이 걸렸습니다하지만 나는 그것이 다른 사용자

+0

'message.text_part'로 충분합니다. 나는 .decoded로부터 어떤 효과도 느끼지 못했다. 나는 또한 .encoded와 .decoded 사이에 어떤 차이도 느끼지 않았다. – Dennis

관련 문제