tags:

views:

151

answers:

3

I am new to PHP & want to we send email from localhost to my gmail address.

I am using ubuntu 9.10 & have already installed libphp-phpmailer from Synaptic Package manager option.

I used:

$to      = "[email protected]";
$subject = "Account Confirmation";
$headers = "From: [email protected]";
$message = "Testing";
$mail = mail($to, $subject, $message, $headers);

if ($mail) {
    echo "Mail sent.";
} else {
   echo "Some Error occur.";
}

And it show Some Error occur.

please help.

Thanks

A: 

Welcome to SO.

assume under "localhost" you mean "windows".
you will need either to install your own mail server or to use some SMTP class, like PHPMailer, to send mail using your IPS's server

Col. Shrapnel
Can you not read that the question specifies the user is on Ubuntu?
Felix
@Felix yes I can not read the text before it was added to question.
Col. Shrapnel
A: 

You don't need PHPMailer (thus the libphp-phpmailer package) to use the mail() function (also, I would recommend swiftmailer over PHPMailer anytime). Also, if you want to use the mail() function you will need a Mail Transport Agent (MTA). I recommend installing the postfix package (it's available by default in Ubuntu, just use sudo apt-get install postfix). After that, your code should output Mail sent. :)

-1 to the other two answers for not reading your question.

Felix
A: 

I'm using sendmail services to intall

apt-get install sendmail

It makes your computer to be mail server and you can send wherever you want with domain that you want...

confiq
MSJ
Check Spam folder and change From: [email protected]
confiq
You'll also need to set sendmail to send mails.. http://ubuntuforums.org/showthread.php?t=196112
confiq