Reputation: 53
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
Upvotes: 3
Views: 317
Reputation: 28094
Instead of relying on the builtin mail
function which needs a working MTA, you could use a library like Swiftmailer to send the mail through an existing SMTP server (e.g. your regular mail address). That way you have the additional bonus of less spam filtering (because spam filters are sometimes very suspicious of mails that were sent from home servers).
Upvotes: 1
Reputation: 2156
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
Upvotes: 1