I am trying to extend the PHP mailer class from Worx by adding a method that allows me to add attachments using string data, rather than the file path.
I came up with something like this:
public function addAttachmentString($string, $name='', $encoding = 'base64', $type = 'application/octet-stream')
{
$path = 'php://memory/' . md5(microtime());
$file = fopen($path, 'w');
fwrite($file, $string);
fclose($file);
$this->AddAttachment($path, $name, $encoding, $type);
}
However, all I get is a PHP warning:
PHP Warning: fopen() [<a href='function.fopen'>function.fopen</a>]: Invalid php:
There are no decent examples with the original documentation, but I found a couple on the Internet (including one here on SO ), and my usage is displayed according to them.
Has anyone had success using this?
- , , ( ) . , script.