About us
Inbuiltweb is a website and application development company building standard platforms to automate manual labour with web technology and bring a secured and organized internet to everyone.
To send an email from PHP, you can use the mail()
function. This function allows you to specify the recipient, subject, and message of the email, as well as other options such as the sender's email address and name. The value/data for each variable can be gotten from a form using HTML and implemented using IF STATEMENT in PHP.
Here is an example of how you can use the mail()
function to send an email:
$to = "[email protected]";
$subject = "Email Subject";
$message = "This is the email message.";
$headers = "From: [email protected]";
if (mail($to, $subject, $message, $headers)) {
echo "Email sent successfully!";
} else {
echo "There was an error sending the email.";
}
This code sets the recipient's email address, subject, and message of the email, as well as the sender's email address. It then uses the mail()
function to send the email, and checks the return value to determine whether the email was sent successfully or not.
Keep in mind that to use the mail()
function, your PHP script must be running on a web server with an email server configured. You may need to consult your web host or system administrator for more information on how to set this up.
Comments section
You need to be logged in to comment, Login or Register.Approved comments:
No comments yet! be the first to comment