To send emails with PHP, you can use the `mail` function. Here’s an example of how to use it:

“`php
$to = “recipient@example.com”;
$subject = “Hello”;
$message = “This is a test email.”;

$headers = “From: sender@example.com\r\n”;
$headers .= “Reply-To: sender@example.com\r\n”;
$headers .= “CC: cc@example.com\r\n”;

// Optional: Add attachments
$attachment = “/path/to/file.pdf”;
$attachments = array($attachment);

// Generate a boundary string
$random_hash = md5(date(‘r’, time()));

$headers .= “Content-Type: multipart/mixed; boundary=\”PHP-mixed-{$random_hash}\””;

// Create the body of the email
$body = “–PHP-mixed-{$random_hash}\r\n”;
$body .= “Content-Type: text/plain; charset=\”utf-8\”\r\n”;
$body .= “Content-Transfer-Encoding: 7bit\r\n\r\n”;
$body .= $message.”\r\n”;

// Add attachments
foreach($attachments as $file){
if(is_file($file)){
$file_size = filesize($file);
$handle = fopen($file, “r”);
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$body .= “–PHP-mixed-{$random_hash}\r\n”;
$body .= “Content-Type: application/pdf; name=\””.basename($file).”\”\r\n”;
$body .= “Content-Transfer-Encoding: base64\r\n”;
$body .= “Content-Disposition: attachment; filename=\””.basename($file).”\”\r\n\r\n”;
$body .= $content.”\r\n”;
}
}

$body .= “–PHP-mixed-{$random_hash}–“;

// Send the email
if(mail($to, $subject, $body, $headers)){
echo “Email sent successfully.”;
} else{
echo “Email could not be sent.”;
}
“`

In this example, you need to replace the following placeholders:

– `$to` with the email address of the recipient.
– `$subject` with the subject of the email.
– `$message` with the contents of the email.
– `$headers` with the appropriate `From`, `Reply-To`, and `CC` headers.
– Optionally, `$attachment` with the path to the file you want to attach.

Make sure you have a correctly configured mail server to send the emails.