23 lines
636 B
PHP
23 lines
636 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class RsvEmailSender {
|
||
|
|
|
||
|
|
private function headers(): array {
|
||
|
|
return [
|
||
|
|
'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>',
|
||
|
|
'Content-Type: text/html; charset=UTF-8',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
private function do_send(string $to, string $subject, string $body): void {
|
||
|
|
$success = wp_mail($to, $subject, $body, $this->headers());
|
||
|
|
if (!$success) {
|
||
|
|
throw new \RuntimeException('wp_mail failed for ' . $to);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function send(string $to, string $subject, string $body): void {
|
||
|
|
$this->do_send($to, $subject, $body);
|
||
|
|
}
|
||
|
|
}
|