up vote 1 down vote favorite
share [g+] share [fb]

I have a home network with an XP and Ubuntu (9.10) box. I have created a small test php script for checking that I can send emails from my machine. I am using the same php.ini file with the same [mail settings], yet the file works on my XP box, and fails on the Ubuntu box. I have included the script here, hopefully, someone can spot whats going wrong:

<?php

// send e-mail to ...
$to="myemail@hotmail.com";

// Your subject
$subject="Test Email";

// From
//$header="from: test script";
$header='From: host-email-username@hostdomain_here . "\r\n" .

// Your message
$message="Hello \r\n";
$message.="This is test\r\n";
$message.="Test again ";

// send email
$sentmail = mail($to,$subject,$message,$header);

// if your email succesfully sent
if($sentmail){
echo "Email Has Been Sent .";
}
else {
echo "Cannot Send Email ";
}
?>

The emails have been spoofed for obvious reasons, but otherwise, the script is exactly as the one I tested

link|improve this question
The syntax highlighting points out an error in your code: you never terminate the string starting From: host-email..., and you don't terminate that line with a semicolon either. Can you verify this is not the case in your actual code? – Samir Talwar Jan 17 '10 at 1:17
That is not the case (its a typo). As I mentioned, the code works correctly on an XP box. Incedentally, I managed to partially resolve this by installing the mailutils package on the Ubuntux box, now the error does not occur in the script (i.e. the message appears to be sent) - however, it never arrives in my mail box. – morpheous Jan 17 '10 at 14:34
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown