Although PHP has built in function mail() to send email, it's quite insecure and use nonobvious arguments. Here is the example of easy-to-use and reliable mail function.
A text email is the simplest email you can possibly send. The code you can use is easy to create and send one is easy too. Firstly I will show you how to send basic text emails from strings coded into the script, then I will finish off this section with a example that uses forms to send form data to an email.
The goal of this tutorial is to demonstrate how to generate and send emails in PHP.
So, you want to send automated email messages from your PHP application.
This can be in direct response to a user's action, such as signing up for your site, or a recurring event at a set time, such as a monthly newsletter.
Sometimes email contains file attachments, both plain text and HTML portions, and so on.
To understand how to send each variation that may exist on an email, we will start with the simple example and move to the more complicated.
Sending a Simple Text Email
Sending HTML Email
Sending Email with Attachments
Joining mailing list will entitle you
to receive occasional emails informing you of news and
updates to the site and any special offers that may be
of interest to you.