2015-11-03 58 views
2

我試圖將一個換行符添加到純文本電子郵件中,經過多次嘗試後,我似乎無法使其工作。這是我迄今爲止所嘗試的:PHP:如何在純文本電子郵件中添加換行符 - 跨平臺

$plain = ""; 
$plain .= "Roll Back Plan:\r\n\r\n"; 
$plain .= "Roll Back Plan:\r\n\"; 
$plain .= "Roll Back Plan:\n\n"; 
$plain .= "Roll Back Plan:\r\r\"; 
$plain .= "Roll Back Plan:\r"; 
$plain .= "Roll Back Plan:\n"; 
$plain .= "Roll Back Plan:" . PHP_EOL; 

到目前爲止還沒有工作。

我很感謝here之前詢問過。

但我已經嘗試了建議的方法,但仍然沒有...

任何想法?

編輯:

這是一個純文本電子郵件

EDIT2:添加原料電子郵件

Received: {{REMOVED}}} by 
    {{REMOVED}}} with Microsoft SMTP Server (TLS) id 14.1.355.2; 
    Tue, 3 Nov 2015 10:22:07 +0000 
    Return-Path: {{REMOVED}}} 
    Received: from {{REMOVED}}} 
    X-Env-Sender: {{REMOVED}}} 
    X-Msg-Ref: {{REMOVED}}} 
    X-Originating-IP: {{REMOVED}}} 
    X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: 
     VHJ1c3RlZCBJUDogOTQuMjM2LjExOS41ID0+IDUzMTM=\n,received_headers: No 
     Received headers 
    X-StarScan-Received: 
    X-StarScan-Version: 7.19.2; banners=-,-,- 
    X-VirusChecked: Checked 
    Received: (qmail 10991 invoked from network); 3 Nov 2015 10:22:06 -0000 
    Received: {{REMOVED}}} 
    (94.236.119.5) by server-3.tower-56.messagelabs.com with 
    DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Nov 2015 10:22:06 -0000 
    X-MSFBL: d2FnbmVyLm1hdG9zQGM0bC5jby51a0BkdnAtOTQtMjM2LTExOS01QGJnLWxvbi0w 
     MUA0NzktTUVCLTI0MjoxNzYzOjIyOTA6MzkzMzowOjI5MzU6NzoxMDkzMjkz 
    DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1446546126; 
     s=m1; d=mktomail.com; [email protected]; 
     h=Date:From:To:Subject:MIME-Version:Content-Type; 
     bh=n1kHPhx5cLCEhc6ci0DYK/AkmvxaGYckMaYngTcfmCM=; 
     b=Nw+P13RuK/SuT1kwJVw1YsC6vlhZBNhBS6PzBcPJeFE2scVxj65d53qFg+hjlUwZ 
     OX4iIFpee8RJeQFX/3ev2GiKm4KN0+Q3V0chfvvEl5kT9ZCWObgQEj56L4UWAgPKMw8 
     YZuX9lw/d1FZH0Al/RjKRD0wjITtpg+fvTxj/nY8= 
    Date: Tue, 3 Nov 2015 04:22:06 -0600 
    From: {{REMOVED}}} 
    Reply-To: {{REMOVED}}} 
    To: {{REMOVED}}} 
    Message-ID: {{REMOVED}}} 
    Subject: {{REMOVED}}} 
    Content-Type: multipart/alternative; 
     boundary="----=_Part_24932112_12312464.1446546126219" 
    X-Binding: bg-lon-01 
    X-MarketoID: 479-MEB-242:1763:2290:3933:0:2935:7:1093293 
    X-MktArchive: false 
    List-Unsubscribe: {{REMOVED}}} 
    X-Mailfrom: {{REMOVED}}} 
    X-MktMailDKIM: true 
    X-MS-Exchange-Organization-AuthSource: {{REMOVED}}} 
    X-MS-Exchange-Organization-AuthAs: Anonymous 
    MIME-Version: 1.0 

    ------=_Part_24932112_12312464.1446546126219 
    Content-Type: text/plain; charset="UTF-8" 
    Content-Transfer-Encoding: quoted-printable 

    {{REMOVED}}} 


    Some text And more text<br>And some even more 


    {{REMOVED}}} 



    {{REMOVED}}} 

    ------=_Part_24932112_12312464.1446546126219-- 
+1

您可以使用簡單的制動器'
'標籤來實現您要找的內容。 – Andrew

+1

如果純文本換行符在純文本郵件中不起作用,那麼您正在將郵件視爲html。這可能是因爲垃圾客戶端或錯誤的內容 - MIME類型。 – DanFromGermany

+0

因爲三個人(三個不同的電子郵件客戶端)看到完全相同的電子郵件(沒有換行符),所以我不認爲這是客戶端問題。我如何定義'content-mime-type'? – WagnerMatosUK

回答

0

您可以撰寫電子郵件正文爲HTML:在這種情況下

可以使用"</br>"標籤換行符

如果你想撰寫電子郵件爲純文本:

使用"\r\n"換行

+0

我已經試過'「\ r \ n」'如我的問題所述,但不幸的是沒有奏效。 – WagnerMatosUK

+0

您在哪個編輯器/客戶端查看電子郵件? 在vi/notepad ++中打開它並查看行尾有哪些字符.. –

相關問題