How log the mail php
In PHP, you can use the mail()
function to send an email. Here is a basic example of how to use it:
<?php
$to = '[email protected]';
$subject = 'Test email';
$message = 'This is a test email sent using PHP';
$headers = 'From: [email protected]'. "\r\n".
'Reply-To: [email protected]'. "\r\n".
'MIME-Version: 1.0'. "\r\n".
'Content-Type: text/plain; charset=UTF-8';
mail($to, $subject, $message, $headers);
?>
This will send an email to the recipient with the specified subject, message, and headers.
Here's a breakdown of the parameters:
$to
: The email address of the recipient.$subject
: The subject of the email.$message
: The body of the email.$headers
: An array of headers to be sent with the email. In this example, we're setting theFrom
,Reply-To
,MIME-Version
, andContent-Type
headers.
You can also use the mail()
function with additional parameters to specify the SMTP server and port:
<?php
$to = '[email protected]';
$subject = 'Test email';
$message = 'This is a test email sent using PHP';
$headers = 'From: [email protected]'. "\r\n".
'Reply-To: [email protected]'. "\r\n".
'MIME-Version: 1.0'. "\r\n".
'Content-Type: text/plain; charset=UTF-8';
mail($to, $subject, $message, $headers, 'smtp.example.com', 587);
?>
This will send the email using the specified SMTP server and port.
Note that the mail()
function is a built-in PHP function, but it's not always reliable and may not work with all email providers. You may need to use a third-party library or service to send emails reliably.