Learn Codeigniter

Send Mail In PHP

To Send mail from PHP, we use mail() function.

Syntax

mail(to,subject,message,headers,parameter);

Example

<?php
$to = "[email protected], [email protected]";//receivers email
$subject = "Send Mail In PHP";
$message = "
<html>
<head>
<title>HTML Email</title>
</head>
<body>
<p>Successfully Test PHP Mail function.</p>
</body>
</html>";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: [email protected]' . "\r\n"; //sender email
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'BCC: [email protected]' . "\r\n";
mail($to,$subject,$message,$headers);
?>