| Parameter | Description |
| to | Required. Specifies the receiver / receivers of the email |
| subject | Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters |
| message | Required. In case any of our lines are larger than 70 characters, we should use wordwrap() |
| headers | Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n). |
<?php
if (! function_exists('send_email')) {
function send_email($to_email, $subject, $message)
{
$headers = '';
$headers .= "Return-Path: Team <Sender email id >\r\n"; //sender email id for return path ex. contect@trickprof.com
$headers .= "From: Team <Sender email id>\r\n"; //from email id ex. contect@trickprof.com
$headers .= 'Cc: cc@gmail.com\r\n';//CC email id
$headers .= "Organization: Team \r\n"; // fill your organization name
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
return mail($to_email, $subject, $message, $headers);
}
}
$to_email='trickprof@gmail.com'; // your to email
$subject='test email'; // your email subject
$message ="<h2> test email </h2>";//your html format email body$mail = send_email($to_email, $subject, $message, $add_reply = false) ;
echo ($mail)?"email sent successfully":"email not sent"; // response ?>
Note:
1) for Multiple recipients
$to_email = 'johny@example.com, sally@example.com'; // note the comma
2)CC for carbon copy. It’s used when you want to send a copy to an interested person i.e. a complaint email sent to a company can also be sent as CC to the complaints board.
BCC for blind carbon copy. It is similar to CC. The email addresses included in the BCC section will not be shown to the other recipients.
We are Recommending you:
- Mastering Git: 3 Hidden Commands Every Developer Should Know
- REST API - Response Codes and Statuses
- ChatGPT vs. DeepSeek: A Simple Comparison
- Git Commands: A Complete Guide for Developers
- SQL vs. MongoDB
- 5 Lesser-Known WordPress Plugins to Supercharge Your Website in 2025
- Git vs. GitHub: Understanding the Difference
- A Comprehensive Guide to OOP in PHP
- Best Practices for Microservices
Master Your Time with the 80/20 Rule: A...
Get Control of Your Time: 6 Easy Ways...
India’s startup space is booming in 2025....
India breeds dreamers who build empires....
Tech in 2025: 35 Fun and Easy Ways to Stay...
Step Out of Your Comfort Zone: 10 Powerful...
In this tutorial, i would like to share with...
VS Code is awesome for coding, and...
Laziness is not just about lying down and...