1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace ICanBoogie\Mailer;
13
14 15 16
17 class MailDeliverer implements Deliverer
18 {
19 public function deliver(Message $message)
20 {
21 $to = (string) $message->to;
22 $subject = (string) $message->subject;
23 $body = (string) $message;
24
25 $charset = mb_detect_encoding($subject);
26
27 if ($charset != 'ASCII')
28 {
29 $subject = mb_convert_encoding($subject, 'UTF-8');
30 $subject = mb_encode_mimeheader($subject, 'UTF-8');
31 }
32
33 $header = clone $message->header;
34
35 unset($header['To']);
36 unset($header['Subject']);
37
38 return mail($to, $subject, $body, $header);
39 }
40 }