Question: I am trying to send a very basic mail with PHP using the below code;

```
if (mail('mymail@gmail.com','Test mail','Testing mail function!'))
{
    echo "Email was sent successfully!";
}
else
{
    echo "Email was not sent!";
}

```

However, the output is always 'Email was not sent'. I am running this script locally on my machine using Xaamp. 

I already tried to research a solution for this but I had no luck. It seems like it's something to do with server configuration. I tried to modify sendmail in php.ini but it still didn't work. 

Any help on this is greatly appreciated.

Thank you.

Answer: 
Try with this library:

[PHPMailer](https://github.com/PHPMailer/PHPMailer)

You can use smtp instead of sendmail.
You need to run Mercury to simulate a mail server, this is a Mercury tutorial: <http://system66.blogspot.com.es/2010/01/how-to-send-mail-from-localhost-with.html>

Or you can use a PHPMailer.