mail function in php


What is needed when using the php function mail to send emails? Email server? Is there any option to use one free? What are the best options?

Thanks in advance.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

gilbertocortezConnect With a Mentor Commented:
Ubuntu does come with a mail server... you can look at for it's features.

Try running this php script on your server, just replace the email adress to your address and if you get it it means that you already have it set up, if you don't then we will go and try to assist you in setting that up for you.

//Change the email to your address
mail("","Testing Mail Function","This is a test message to test the mailing capabilities");


Open in new window

Normally it's using the local mailer (sendmail).

See the requirements here:

and runtime configuration:

Most of the time you use the mailer on the server you're hosting your website on. Try it and see if it works - it should run without any further configuration.
lulonAuthor Commented:
Note: I'm using Ubuntu
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Then I assume you're having problems sending e-mails using the PHP mail() function on your localhost, yes?
lulonAuthor Commented:
I haven't even tried yet. I have the code and I know it works cause it has been tested but not in my computer.
lulonAuthor Commented:
I will try to configure it.

But, do you normally have to have any kind of contract or similar with your ISP in order to be able to send emails to another accounts? Is it normally free or does it cost money?
karoldvlConnect With a Mentor Commented:
No, with most normal providers you can do what you want. And with Ubuntu you should be able to do it out of the box.
hi ,

mail function working when smtp server is you have mail server then you can implement this and see email.
All Courses

From novice to tech pro — start learning today.