Hi all -
Trying to get an email form script working in a Linux environment. The script works just fine in a Windows environment (collects data from form, attaches message and emails it), but when run in a Linux environment, the email looks weird.
Basically when you receive the email, it has all the MIME codes exposed and visible in the body of the email, and worse, the attachment seems to get sent as text - you can see all the hex codes that make up the files as text at the end of the email.
My question is: is there some change I need to make to the code when running on a Linux server vs a Windows server? Any help very much appreciated - thanks!
A
Email Script Windows vs Linux
Moderator: General Moderators
sometimes weird things happen if you use \r\n to terminate line endings in the headers on *nix, but you MUST use \r\n on win
i use this to get around it, maybe it will solve your problem
i use this to get around it, maybe it will solve your problem
Code: Select all
function send_email($from, $to, $subject, $message)
{
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: <$from>\n";
$headers .= "Reply-To: <$from>\n";
if (false !== strpos(PHP_OS, 'WIN')) {
$headers = str_replace("\n", "\r\n", $headers);
}
return (mail($to, $subject, $message, $headers));
}