2017-09-25 4 views
0

임시 이메일 웹 사이트에서 작업 중입니다. 구현해야하는 기능 중 하나가 (이메일의 헤더를 가져 오는) 이메일의 원본을 가져 오는 것이므로이 코드를 구현했습니다. 이를 위해 :response.data가 PHP 백엔드에서 전송되었습니다.

백엔드 (PHP) :

function get_original_email($mailid, $address) { 
global $mailbox; 

if (_load_one_email($mailid, $address) !== null) { 
    header('Content-type: application/json'); 
    $headers = imap_fetchheader($mailbox->getImapStream(), $mailid, FT_UID); 
    //$body = imap_body($mailbox->getImapStream(), $mailid, FT_UID); 
    print (json_encode(array('originalEmail' => $headers))); 
} else { 
    error(404, 'retrieving error: invalid username/mailid combination'); 
} 

}

AngularJS와 컨트롤러 :

self.getOriginal = function (mail, domain) { 

    var firstTo = Object.keys(mail.to)[0]; 
    $http.get(backend_url, {params:{username: firstTo, original_email_id: mail.id, domain:domain}}) 
     .then(
      function successCallback(response) { 
       self.originalEmail = response.data.originalEmail; 
       $log.error(response); //To show response content. 
      }, 
      function errorCallback(response) { 
       $log.error(response, this); 
       self.error = { 
        title: "HTTP_ERROR", 
        desc: "There is a problem with geting the original email. (HTTP_ERROR).", 
        detail: response 
       }; 
      }); 
} 
{data: "", status: 200, config: {…}, statusText: "OK", headers: ƒ}config: {method: "GET", transformRequest: Array(1), transformResponse: Array(1), jsonpCallbackParam: "callback", paramSerializer: ƒ, …}data: ""headers: ƒ (d)status: 200statusText: "OK"__proto__: Object 

내가 헤더의 내용을 downloded :

이 코드는 내가 예를 들어 Blockchain.com 위해 가입하려고 할 때 이메일의 대부분을하지만은, 원본을 점점 실패하고 내가 크롬 관리자에서이 얻을 잘 작동 : 내가 직접로 json_encode를 사용하지 않고 인쇄를 사용하는 다운로드 기능의 내용을 얻고 있기 때문에

Return-path: <[email protected]> 
Envelope-to: [email protected] 
Delivery-date: Mon, 25 Sep 2017 18:25:32 +0200 
Received: from o1.mail.blockchain.info ([198.21.6.174]) 
    by with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) 
    (Exim 4.89) 
    (envelope-from <[email protected]>) 
    id 1dwWCK-0008U5-Eu 
    for [email protected]; Mon, 25 Sep 2017 18:25:32 +0200 
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; 
    d=blockchain.info; 
    h=content-transfer-encoding:content-type:from:mime-version:subject:to; 
    s=m1; bh=A+wGBBGT0nPZi611WDiY8hyoJiA=; b=BvDSkuUQpbkbwvS176xTK19 
    evW+h0n9QLlMlqNQRy8pEZXRaMtPm3o9szysUlrzFB8+ucaSyCQqhdjobKRA5LvP 
    L5BS9814iqFpV+Kzrb8gMc3aSl/aycBTqBxQYeuTtsWWT1I6VMHLPquVqOuS4ZjG 
    n1ia1O5mFsFtvNJpligI= 
Received: by filter0934p1mdw1.sendgrid.net with SMTP id filter0934p1mdw1-27911-59C92DF5-1D 
     2017-09-25 16:25:25.327461844 +0000 UTC 
Received: from MTc3MjI3NQ (236.212.190.35.bc.googleusercontent.com [35.190.212.236]) 
    by ismtpd0001p1lon1.sendgrid.net (SG) with HTTP id 8U6IPbOfSEO07nzJUAkd1Q 
    for <[email protected]>; Mon, 25 Sep 2017 16:25:25.209 +0000 (UTC) 
Content-Transfer-Encoding: quoted-printable 
Content-Type: text/html; charset=UTF-8 
Date: Mon, 25 Sep 2017 16:25:25 +0000 (UTC) 
From: "Blockchain" <[email protected]> 
Mime-Version: 1.0 
Subject: Welcome To My Wallet 
To: [email protected] 
Message-ID: <[email protected]> 
X-SG-EID: rp6B7bPLkmILpCROEdQ6zxTTWV8/jMJblylXDv403K5XiCqxnco7VnA/3IqSz7BIqYEji4cv4ijjl3 
obxT0otJleksoYG645Y4eGShknp4SWqOkaFs63Ycjvax2oooiiWDaX5/JGhenxjRDma8xla9eBS4Fg 
kwS3NpJQZSN3iSig19KAiQSGMIT4FhORo8kD0hDQAJhfzUT/JT1pcnAx8mMsZ9/JyELfQe9pet+yLB 
8= 
X-Spam-Score: 10 
X-Spam-Bar: + 
X-Spam-Report: Spam detection software, running on the system "", has 
identified this incoming email as possible spam. The original message 
has been attached to this so you can view it (if it isn't spam) or label 
similar future email. If you have any questions, see 
the administrator of that system for details. 

Content preview: Verify Your Email Thank you for creating a Blockchain wallet. 
    Verify your email below to complete your setup. Yes, This Is My Email Your 
    Wallet ID: 8a622806-96bd-44f3-a267-77f5af68a3dd Use your unique Wallet ID 
    to log into your Blockchain wallet. Copyright © 2017 Blockchain Luxembourg 
    S.A. All rights reserved. Click here to Unsubscribe [...] 

Content analysis details: (1.0 points, 5.0 required) 

    pts rule name    description 
---- ---------------------- -------------------------------------------------- 
    0.0 URIBL_BLOCKED   ADMINISTRATOR NOTICE: The query to URIBL was blocked. 
          See 
          http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block 
           for more information. 
          [URIs: blockchain.info] 
    0.0 HTML_MESSAGE   BODY: HTML included in message 
    1.1 MIME_HTML_ONLY   BODY: Message only has text/html MIME parts 
-0.1 DKIM_VALID_AU   Message has a valid DKIM or DK signature from author's 
          domain 
    0.1 DKIM_SIGNED   Message has a DKIM or DK signature, not necessarily valid 
-0.1 DKIM_VALID    Message has at least one valid DKIM or DK signature 
X-redirected: yes 

'(A JSON 형식을 보낼 수), 그래서 문제가 JSON 형식으로이라고 생각,하지만 난 돈 t 문제가 정확히 무엇인지, 그래서 당신이 공유에 대해 감사드립니다.

+0

오류 메시지 당 eMail이 스팸으로 감지되었습니다. 이 링크를 확인하십시오 - https://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block – ManishSingh

+0

요청이 차단 목록에 있으며, 원본을 검색 할 수 없다는 것을 의미합니까 ?? – SADMI

+0

나는 eMail의 수에 제한이 있으며 그것이 모두 소비되지만 나는 100 % 확실하지 않다고 생각한다. – ManishSingh

답변

0

문제는 메시지 내용합니다 ($headers)에 나타날 수있는 몇 가지 특수 문자, 그래서 나는이 기능을 만들어 그것을 위해, 그들을 청소해야 :

function _clean_origin($origin){ 
    $origin = preg_replace('/[^\da-z \n\rA-Z.,!<>()+-?]/'," ",$origin); 
    return $origin; 

}

을하는 get_original_email에서 $headers을 청소하라고 요청하므로 정상적으로 머리글을 얻을 수 있습니다.