Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mail() function on localhost

I have problem with php mail() function on localhost server. I can't test my email application on localhost when i'm trying to send emails with php function mail().

I'm getting this error Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\wamp\www\product\ajax.php on line 64

I'm using WAMP server and if anyone knows solution please help me.

like image 511
Shark Avatar asked Mar 17 '11 17:03

Shark


Video Answer


1 Answers

You need to setup a mail server on your machine for the mail function to work. If you are on Windows (which I am guessing you are from your use of WAMP) you can setup a Pegasus mail server.

Other options include using a wrapper class such as SwiftMailer or PHPMailer and using them to connect to another SMTP server such as your GMail account. Even if you go the Pegasus mail server on your own localhost route then I would still recommend using one of the two classes I have mentioned above. They give you far more flexibility and are safer.

Connecting to either your ISPs SMTP server or GMail or whatever is the easiest route out of this one.

like image 187
Treffynnon Avatar answered Oct 05 '22 04:10

Treffynnon