Sending Emails using PHP

sending emails using php

Sending Emails using PHP

Sending emails using php can be done by the mail() function.

If you are looking for codeigniter mail function please click here.

In this article we will discuss sending emails using php. It can be done by the php mail() function. The mail() function requires three mandatory parameters: to address, subject of mail and the message . The additional parameters are headers and parameters.

PHP : mail.php

$to = "";
$subject = "HTML email";
$from = '';
$message = '
<title>HTML email</title>
<p>This email contains HTML Tags!</p>
<table border="1">

// More headers
$headers  = 'MIME-Version: 1.0' . "\r\n";
// Always set content-type when sending HTML email
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: " .$from."\r\n"."X-Mailer: php";

  1. declare to address, subject, from address and message
  2. MIME Version (Multi-Purpose Internet Mail Extensions) – Defines version of the MIME protocol. It must have the parameter Value 1.0, which indicates that message is formatted using MIME.
  3. Content-type – the content type of email body. There are different types like text, html, video, audio
  4. send mail using the mail() function and pass parameters to, subject, message and headers.

Refer php mail function for more details.

One thought on “Sending Emails using PHP

Leave a Reply

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

Back To Top