$message = new Message('recipient@example.com', 'sender@example.com', 'Hello', 'This is a test message');
class CustomMessage extends Message { public function __construct($recipient, $sender, $subject, $body, $cc) { parent::__construct($recipient, $sender, $subject, $body); $this->addCc($cc); } private function addCc($cc) { $this->setHeader('Cc', $cc); } } $message = new CustomMessage('recipient@example.com', 'sender@example.com', 'Hello', 'This is a test message', 'cc@example.com');In this example, we create a custom class called CustomMessage that extends the Message class. We override the __construct method to add a CC field to the message. We then create a new instance of CustomMessage and set the recipient, sender, subject, body, and CC fields. This code example may belong to a package library such as PHPMailer or SwiftMailer, but it may be a custom package library created by the developer.