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); }
<?php require_once '../../bootstrap.php'; use Pop\Mail\Mail; try { $rcpts = array(array('name' => 'Test Smith', 'email' => '*****@*****.**'), array('name' => 'Someone Else', 'email' => '*****@*****.**')); $mail = new Mail('Hello World!', $rcpts); $mail->from('*****@*****.**', 'Bob'); $mail->setText("Hello [{name}],\n\nI'm just trying out this new Pop Mail component.\n\nThanks,\nBob\n\n"); // Save emails to a file format that can later be sent // by the Pop\Mail component or another external email // program, such as qmail, sendmail, etc. $mail->saveTo('../tmp'); // Use the Pop\Mail component to send the saved email files. //$mail = new Mail(); //$mail->sendFrom('../tmp', true); echo 'Mail Saved!'; } catch (\Exception $e) { echo $e->getMessage(); }