function __construct($headers, $options) { parent::__construct(); $this->headers =& $headers; $this->options =& $options; empty($options['testMode']) || p::log('pMail-construct', $this->setTestMode()); $this->setHeaders(); if (!empty($options['attachments']) && is_array($options['attachments'])) { $tmpToken = isset($options['attachments.tmpToken']) ? '~' . $options['attachments.tmpToken'] : false; foreach ($options['attachments'] as $name => $file) { if (!file_exists($file)) { user_error(__CLASS__ . ': file attachment not found (' . $file . ')'); continue; } is_int($name) && ($name = ''); $c_type = strtolower(strrchr($name ? $name : $file, '.')); $c_type = isset(p\StaticResource::$contentType[$c_type]) ? p\StaticResource::$contentType[$c_type] : 'application/octet-stream'; $this->addAttachment($file, $c_type, $name); $tmpToken && $tmpToken === substr($file, -strlen($tmpToken)) && register_shutdown_function(array(__CLASS__, 'unlink'), $file); } } }