2012-04-02 34 views
2
$message = 'New user registration\n\n 
There is a new submission on the site and below are the details.\n\n'; 

我試圖使用html,但它顯示電子郵件中的文本,所以我將其更改爲純文本。仍然不能換行。電子郵件 - 在電子郵件中做新行的正確方法是什麼?

我不知道爲什麼它不能按我的想法工作。

編輯#2

$umessage .= '<a href="'.$pdflink.'">Download Brochure</a>'; 

的問題是,它顯示在電子郵件:Download Brochure

有周圍沒有任何辦法嗎?

回答

5

當您使用單引號字符串時,不會解釋換行符。你需要使用"來封裝你的字符串。

此外,您應該使用\r\n與郵件客戶端兼容。

$message = "New user registration\r\n 
There is a new submission on the site and below are the details.\r\n"; 
+0

有沒有辦法繞過href鏈接? – joe 2012-04-02 05:57:15

+0

請創建一個新問題。你應該問每個職位一個問題。 – 2012-04-02 06:42:37

+0

「當您使用單引號字符串時,不會解釋換行符。」這是重要的。感謝你的回答。 – 2017-11-02 07:22:35

3

嘗試使用「\ r \ n」作爲換行符。

$message = 'New user registration\r\n 
There is a new submission on the site and below are the details.\r\n'; 
+0

感謝您的快速回復。你幫了!有效。 – joe 2012-04-02 05:07:03

+0

使用它兩次會破壞多條線嗎? – joe 2012-04-02 05:11:16

+0

這是正確的。還請注意burhan的回答,他提出了一個關於使用包含換行符的字符串的雙引號的好處。 – BluesRockAddict 2012-04-02 05:12:58

相關問題