public function test_get_header_value() { $mail = new SMail($this->date); $mail->set_from('*****@*****.**', 'Foo Bar'); $mail->add_to('*****@*****.**', 'John Doe'); $mail->add_cc('*****@*****.**'); $mail->add_cc('*****@*****.**', 'Raphael Rougeron'); $mail->set_subject('Stop these useless meetings...'); $this->assertEquals('John Doe <*****@*****.**>', $mail->get_to()); $this->assertEquals('Foo Bar <*****@*****.**>', $mail->get_from()); $this->assertEquals('jane.doe@fake.net, Raphael Rougeron <*****@*****.**>', $mail->get_cc()); $this->assertEquals('', $mail->get_bcc()); $this->assertEquals('Stop these useless meetings...', $mail->get_subject()); }
protected function create($method_name, $args) { $mail = new SMail($this->date); if (is_array($this->from)) $mail->set_from($this->from[0], $this->from[1]); else $mail->set_from($this->from); if (!is_array($this->recipients)) $this->recipients = array($this->recipients); foreach ($this->recipients as $to) { if (is_array($to)) $mail->add_to($to[0], $to[1]); else $mail->add_to($to); } $mail->set_subject($this->subject); if (is_array($this->body)) { $template = $this->get_template_name($method_name); if (file_exists($this->get_template_path($template.'.plain'))) $mail->set_text($this->render($template.'.plain', $this->body)); if (file_exists($this->get_template_path($template.'.html'))) $mail->set_html_text($this->render($template.'.html', $this->body)); } elseif (is_string($this->body) && !empty($this->body)) { $mail->set_text($this->body); } foreach ($this->parts as $p) { $p = array_merge(self::$part_defaults, $p); $mail->add_part($p['content'], $p['content_type'], $p['encoding'], $p['charset']); } foreach ($this->attachments as $a) { $a = array_merge(self::$attachment_defaults, $a); $mail->add_attachment($a['content'], $a['filename'], $a['content_type'], $a['encoding']); } $this->reset(); return $mail; }