Send email from localhost to Gmail

I am new to PHP and want us to send email from localhost to my gmail address.

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

I used:

$to      = "abc@gmail.com";
$subject = "Account Confirmation";
$headers = "From: xyz@gmail.com";
$message = "Testing";
$mail = mail($to, $subject, $message, $headers);

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

      

And it shows that an error has occurred.

+2


a source to share


3 answers


I am using sendmail to intall services

apt-get install sendmail



This makes your computer a mail server and you can send wherever you want with the domain you want ...

0


a source


Welcome to SO.



Suppose that by "localhost" you mean "windows".
you need to either install your own mail server or use some kind of SMTP class, for example PHPMailer

to send mail using your IPS server

-1


a source


You don't need PHPMailer (thus a package libphp-phpmailer

) to use the function mail()

(also I would recommend swiftmailer via PHPMailer at any time). Also, if you want to use the feature mail()

, you need a Mail Transfer Agent ( MTA ). I recommend installing the package postfix

(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.

-1


a source







All Articles