我正在尝试将纯文本电子邮件发送给将为我处理它们的公司。我正在使用 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: someone@somewhere.com 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: someone@somewhere.com
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
该公司表示,他们认为线索是以自由文本而不是纯文本形式发送的。有这样的事吗?我从未听说过自由文本。
预先感谢您的帮助。