PHP mail() function

PHP mail() function

In this lesson we are going to show you a sample PHP script on how to send email using the PHP mail() function.

PHP mail() function arguments

  1. The email address of your recipients
  2. Email subject line (ex. Meeting, Party)
  3. The body of the message
  4. List of email header fields like “From”, “Cc”
  5. Other parameters

Note: the email address and the body of the message is the most important one, the rest are optional.

Here’s how to send a plain text email using the mail() function

<title>The PHP mail() function</title>
mail("", "Party", "TGIF, time to party");

Save the file as simpleEmailScript.php and upload it to your webserver.

Where: is the address of our recipient, “Party” is the subject line the “TGIF, time to party” is our message of the body

Note: if you want to add another email address just use a comma (,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.