Sending emails from the localhost is not easy. You need to setup the mailer on your machine. This is not something that you would need to do on a normal server as it comes installed almost systematically.
There have been other posts on the forum about trying to install it on local machines and it seems like it’s a bit hard to do.
i have installed postfix for sending mail from localhost . now i am getting message that email has been sent but in my mail i have not received any mail. not even in spam.
The Kirby email() function works with the PHP mail() function by default. You don’t need to configure anything to use it (besides the php.ini settings).
However the PHP mail() function unfortunately is very hard to debug, it doesn’t return a detailed error message.
If you don’t get an error message with your php.ini configuration, that means that the email has been accepted by sendmail. However it does not mean that the email could be delivered to your recipient’s mailbox. Some email providers straight up block emails from home networks because of spam. So it will probably work on a real web server out of the box.
but from my above code , initially i was getting that email could not sent. then i install postfix and now i am getting that email has been sent. but email is not deliver to any account.
can you help to find out where is the mistake or is there any alternative way?
As I wrote above: Because you don’t get an error anymore, that means that your setup is probably correct. However some email providers block email from home networks. Only way to test your code reliably is on a “real” server.