I'm trying to send a simple text-only email with an attachment. Everything's working great so far aside from line-breaks being properly inserted. Code:
$text = 'Product Name: '.$exchange;
$text .= '
Company Name: '.$company_name;
$text .= '
Contact Name: '.$contact_name;
$text .= '
Contact Email: '.$contact_email;
$text .= '
Website: '.$website;
$text .= '
Description: '.$description;
$subject = "I'm interested in signing up.";
$visitor_email = 'blah@blah.com';
$crlf = "
";
$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';
}
In the email, all the text is on one line with 's between where I wanted the lines. Anyone know what might be up? Thanks.
put your $text in double quot instead of single
<?php
$text = 'Product Name: '.$exchange;
$text .= "
Company Name: ".$company_name;
....
You should put not just /n, also put them on the end not beginning
$text .= 'Company Name: '.$company_name.'
';
$text .= 'Contact Name: '.$contact_name.'
';
$text .= 'Contact Email: '.$contact_email.'
';
$text .= 'Website: '.$website.'
';
$text .= 'Description: '.$description.'
';
are end of line characters for Windows systems and is the end of line character for UNIX systems.