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 = "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 show Some Error occur.
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...
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.