Can not send mail by php-script

advertisements

I found a php-script on internet:

<?php
$to = "*******@yahoo.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "****@*****.nu";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

and it work perfectly if I use it from my web-hotel. But i need it to by run on my home-server and I just simply not receiving anything. I tried to run it with php -f phpTest, and through both local ip (10.0.0.2) and by using a global hostname. I just get "Mail send" without getting the mail.

It is a ubuntu-server I am running at and it uses apache2. Like I said, it is no wrong in script because it worked on web-hotel. It should be something with my local settings, but I can't figure out what.

All help would be appreciated!

\\demon


The PHP mail function uses a local MTA (Mail Transport Agent), that is a mail deamon running on the same machine as your PHP interpreter and your Apache web server.

So you must install and configure one on your Ubuntu setup. sendmail is the classic one, but exim is said to be easily configurable, and can use your current SMTP server as a smarthost relay, which works well for a home server.

sudo apt-get install exim4-daemon-light
sudo dpkg-reconfigure exim4-config