$to = 'recipient@example.com'; $subject = 'Attachment Test'; $message = 'Check out the attached file.'; $file = 'path/to/attachment.pdf'; $headers = 'From: sender@example.com'; mail($to, $subject, $message, $headers, ['attachment' => $file]);