$rcpts = array(array('name' => 'Test Smith', 'email' => '*****@*****.**'), array('name' => 'Someone Else', 'email' => '*****@*****.**')); $html = <<<HTMLMSG <html> <head> <title> Test HTML Email </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <h1>Hello [{name}]</h1> <p> I'm just trying out this new Pop Mail Library component. </p> <p> Thanks,<br /> Bob </p> </body> </html> HTMLMSG; $mail = new Mail('Hello World!', $rcpts); $mail->from('*****@*****.**', 'Bob')->setHeaders(array('X-Mailer' => 'PHP/' . phpversion(), 'X-Priority' => '3')); $mail->setText("Hello [{name}],\n\nI'm just trying out this new Pop Mail component.\n\nThanks,\nBob\n\n"); $mail->setHtml($html); $mail->send(); echo 'Mail Sent!'; } catch (\Exception $e) { echo $e->getMessage(); }
public function testSaveTo() { $m = new Mail('Subject', array('name' => 'Bob Smith', 'email' => '*****@*****.**'), 'Hello World'); $m->setHtml('Hello'); $m->setText('Hello'); $m->saveTo(__DIR__ . '/../tmp'); $d = new Dir(__DIR__ . '/../tmp'); $files = $d->getFiles(); $exists = false; foreach ($files as $file) { if (strpos($file, 'popphpmail') !== false) { $exists = true; unlink(__DIR__ . '/../tmp/' . $file); } } $this->assertTrue($exists); }