wp_mail(): Send Helper
-
Static method in
TestCase
"sends" the mail
abstract class TestCase extends PHPUnit_Framework_TestCase {
public static function mail_to_file($to, $subject, $message) {
if (!self::$mail_file_basename) {
throw new Exception('wp_mail() called at unexpected time'
. ' (mail_file_basename was not set).');
}
if (!self::$temp_dir) {
self::$temp_dir = sys_get_temp_dir();
}
// Keep Windows happy by replacing :: in method names with --.
$basename = str_replace('::', '--', self::$mail_file_basename);
self::$mail_file = self::$temp_dir . '/' . $basename;
$contents = 'To: ' . implode(', ', (array) $to) . "\n"
. "Subject: $subject\n\n$message";
return file_put_contents(self::$mail_file, $contents, FILE_APPEND);
}
}