Send email using PHP script

A basic and simple article for the beginners who want know about how to to send email using php.

In this article, we will use HTML form to get data from the user and send an email using PHP script. PHP mail() function is used to send an email. We can send both simple/text emails and also HTML emails. First, we will learn about how to send email using PHP.

HTML form

Following is the HTML form which will be used to fill the required data.

Send email using php

Following is the script which will be used to send an email using PHP. Create new file named as “process_email_form.php” for script.

The above script initially get the form data and then applies check on them if any field was left empty. Finally, mail() function is used in order to send email using php script.

This was all about sending simple text email and using mail() function. You can play with the code to add validation and error checks.

Next article will be about sending HTML email in PHP.

Other related articles:

use php mail functions to send email