我正在尝试发送带有附件的简单纯文本电子邮件。到目前为止,除了正确插入换行符之外,一切都运行良好。代码:
$text = 'Product Name: '.$exchange;
$text .= '\nCompany Name: '.$company_name;
$text .= '\nContact Name: '.$contact_name;
$text .= '\nContact Email: '.$contact_email;
$text .= '\nWebsite: '.$website;
$text .= '\nDescription: '.$description;
$subject = "I'm interested in signing up.";
$visitor_email = 'blah@blah.com';
$crlf = "\n";
$message = new Mail_mime($crlf);
$message->setTXTBody($text);
$message->addAttachment($path_of_uploaded_file);
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send('blah@blah.com', $headers, $body);
if (PEAR::isError($mail)) {
echo($mail->getMessage());
}
else {
echo("Your request has been submitted successfully. Thanks!");
header("Location: home.html");
die();
}
} else {
// submitNoLogo();
echo 'not sent';
}
在电子邮件中,所有文本都在一行中,\n 在我想要的行之间。有谁知道可能会发生什么?谢谢。