mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Allow for alternative names to be supplied
This commit is contained in:
@@ -328,11 +328,12 @@ class WireMail extends WireData implements WireMailInterface {
|
||||
* @return this
|
||||
*
|
||||
*/
|
||||
public function attachment($value) {
|
||||
public function attachment($value, $filename = '') {
|
||||
if(is_null($value)) {
|
||||
$this->mail['attachments'] = array();
|
||||
} else if(is_file($value)) {
|
||||
$this->mail['attachments'][] = $value;
|
||||
$filename = $filename ?: basename($value);
|
||||
$this->mail['attachments'][$filename] = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -389,10 +390,9 @@ class WireMail extends WireData implements WireMailInterface {
|
||||
}
|
||||
|
||||
// Attachments
|
||||
foreach ($this->attachments as $file) {
|
||||
foreach ($this->attachments as $filename => $file) {
|
||||
$content = file_get_contents($file);
|
||||
$content = chunk_split(base64_encode($content));
|
||||
$filename = basename($file);
|
||||
|
||||
$body .= "--$boundary\r\n" .
|
||||
"Content-Type: application/octet-stream; name=\"$filename\"\r\n" .
|
||||
|
@@ -94,9 +94,10 @@ interface WireMailInterface {
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $filename
|
||||
* @return this
|
||||
*
|
||||
public function attachment($value);
|
||||
public function attachment($value, $filename = '');
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user