to = $email; } public function setSubject($subject) { $this->subject = $subject; } public function setMessage($message) { $this->message = $message; // Convert new lines to HTML
tags } public function addHeader($header) { $this->headers[] = $header; } public function addAttachment($filePath) { $this->attachments[] = $filePath; } public function sendMail() { if (empty($this->to) || empty($this->subject) || empty($this->message)) { return false; // Ensure required fields are set } return wp_mail($this->to, $this->subject, $this->message, $this->headers, $this->attachments); } } // Basic Email Notification // $email = new Email_Notifier(); // $email->setSubject('🔔 Security Alert: File Change Detected'); // $email->setMessage('We detected a file modification on your WordPress site. Please review the changes.'); // $email->send(); // Sending Email to a Specific User // $email = new Email_Notifier('user@example.com'); // $email->setSubject('🎉 Welcome to Our Site'); // $email->setMessage('Thank you for registering! Enjoy your stay.'); // $email->send(); // Sending Email with Attachments // $email = new Email_Notifier(); // $email->setSubject('📄 Your Invoice'); // $email->setMessage('Please find your invoice attached.'); // $email->addAttachment('/path/to/invoice.pdf'); // $email->send(); // Custom Email Headers (Reply-To, CC, BCC) // $email = new Email_Notifier(); // $email->setSubject('🔔 Login Attempt Alert'); // $email->setMessage('A failed login attempt was detected from IP: 192.168.1.1'); // $email->addHeader('Reply-To: support@example.com'); // $email->addHeader('CC: manager@example.com'); // $email->addHeader('BCC: security@example.com'); // $email->send();