PHP mail() Function:
The php mail() function is a built-in PHP feature that allows the user to send email directly from a php script. PHP mail function allows the user to directly communicate with the client. you can use this function on your coding to send the emails automatically without manual input from your side. PHP mail function normally used in contact forms when the user visits your website and contact you through a contact form and to send a copy of the message to your mail.
PHP mail() Function Syntax
The basic syntax for mail function is:
mail ($to, $subject, $message,$headers);
to- This parameter indicates the receiver of the mail address, for example, email@example.com
subject- This parameter indicates a brief introduction about the mail, for example, ” payment received”, “Account credentials”
message- This parameter indicates the detailed information about the mail.
headers- This parameter indicates information such as CC, BCC
Let’s now look at simple example mail function php script.
$to = ‘firstname.lastname@example.org’;
$subject = ‘Testing PHP Mail’;
$message = ‘This mail is sent using the PHP mail function’;
$headers = ‘From: email@example.com’;
We hope that this article will help you to How to setup the PHP mail() Function in your website. For more information, follow us on the social media of Facebook and Twitter.