浏览代码

Merge pull request #197 from mp-network-development/bugfix/email

Fix email attachments via https
Mark Sch 8 年之前
父节点
当前提交
a8bea3cd87
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/Mailer/Email.php

+ 5 - 2
src/Mailer/Email.php

@@ -9,6 +9,7 @@ use InvalidArgumentException;
 use Psr\Log\LogLevel;
 use Tools\Utility\Mime;
 use Tools\Utility\Text;
+use Tools\Utility\Utility;
 
 class Email extends CakeEmail {
 
@@ -216,8 +217,10 @@ class Email extends CakeEmail {
 				$fileInfo['data'] = chunk_split(base64_encode($fileInfo['data']), 76, "\r\n");
 			} else {
 				$fileName = $fileInfo['file'];
-				$fileInfo['file'] = realpath($fileInfo['file']);
-				if ($fileInfo['file'] === false || !file_exists($fileInfo['file'])) {
+				if (!preg_match('~^https?://~i', $fileInfo['file'])) {
+					$fileInfo['file'] = realpath($fileInfo['file']);
+				}
+				if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
 					throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
 				}
 				if (is_int($name)) {