Send email with a template using php
To send an email using PHP, you can use the "mail()" function. Here is an example of a basic email template:
<?php
$to = "[email protected]";
$subject = "Test Email";
$message = "This is a test email sent using PHP.";
$headers = "From: Sender <[email protected]>\r\n";
mail($to, $subject, $message, $headers);
?>
Watch a video course
Learn object oriented PHP
In this example, an email is sent to the address "[email protected]" with the subject "Test Email" and the message text "This is a test email sent using PHP." The "From" header is set to "Sender [email protected]".
Note: The mail() function uses the local Mail Transfer Agent (MTA) on the server where the PHP script is running to send the email. Therefore, a configured MTA must be present on the server for the email to be sent successfully.