2012-07-19 188 views
1

我試圖將純文本電子郵件發送給將爲我處理它們的公司。我使用Swift Mailer庫,據我所知 - 我沒有問題。但是我發送信息的公司表示,他們正在將所有數據集中在一條線上。當我使用這個腳本給自己發送一封電子郵件時,它看起來很完美 - 每條數據都在一個單獨的行上。發送純文本電子郵件

這是我正在使用的腳本。這很簡單。

<?php 
$to=""; 

$bcc=""; 

$subject = "Quote" ; 

$domain = $_SERVER['HTTP_HOST']; 

    //Message 
$message = "Domestic Quote Request\n"; 
$message .= "Full Name: $_POST[name]\n"; 
$message .= "Email: $_POST[email]\n"; 
$message .= "Phone: $_POST[phone]\n"; 
$message .= "Pickup Date: $_POST[shipdate]\n"; 
$message .= "Pickup City or Zip: $_POST[pickupzip]\n"; 
$message .= "Drop Off City or Zip: $_POST[dropoffzip]\n"; 
$message .= "Year: $_POST[vehicleyear]\n"; 
$message .= "Make: $_POST[vehiclemake]\n"; 
$message .= "Model: $_POST[vehiclemodel]\n"; 
$message .= "Carrier Type: $_POST[carriertype]\n"; 
$message .= "This Quote is from $domain"; 


require_once 'lib/swift_required.php'; 

// Create the Transport 
// Mail 
$transport = Swift_MailTransport::newInstance(); 

// Create the Mailer using your created Transport 
$mailer = Swift_Mailer::newInstance($transport); 

// Create the message 
$the_message = Swift_Message::newInstance() 

// Give the message a subject 
->setSubject($subject) 

// Set the From address with an associative array 
->setFrom($_POST['email']) 

// Set the To addresses with an associative array 
->setTo(array($to)) 

->setEncoder(Swift_Encoding::get8BitEncoding()) 

// Give it a body 
->setBody($message, 'text/plain', 'us-ascii'); 

//Check is BCC Field is emtpy. 
if (!empty($bcc)) 
{ //The BCC Field is not empty so set it. 
    $the_message->setBcc(explode(',', $bcc)); 
} 

// Send the message 
$result = $mailer->send($the_message); 
    } 
    header("location:index.php?s=1"); 
?> 

這裏是該公司說,他們收到的一個例子:

Domestic Quote Request Full Name: Test Email: [email protected] Phone: 555-555-5555  Pickup Date: 07/02/2012 Pickup City or Zip: 12938 Drop Off City or Zip: 23981 Year: 2009 Make: Audi Model: A4 Carrier Type: enclosed carrier This Quote is from awebsite.com 

而且這是我收到的時候我發給自己。

Domestic Quote Request 
Full Name: Test 
Email: [email protected] 
Phone: 555-555-5555 
Pickup Date: 07/02/2012 
Pickup City or Zip: 12938 
Drop Off City or Zip: 23981 
Year: 2009 
Make: Audi 
Model: M4 
Carrier Type: enclosed carrier 
This Quote is from awebsite.com 

該公司表示,他們認爲,鉛是作爲自由文本而不是純文本發送。有這樣的事嗎?我從來沒有聽說過自由文本。

非常感謝您的幫助。

回答

0

我能想到的唯一事情就是他們正在查看電子郵件的Web客戶端使用HTML解析電子郵件。因此,也許\ n試試<br />

0

電子郵件正文需要Microsoft \ r \ n行尾。 標題需要Linux \ n行尾。

相關問題