From a674addd2a717a55e3b2271d918189f764b882ab Mon Sep 17 00:00:00 2001 From: Joshua Chamberlain Date: Fri, 5 Sep 2014 15:07:55 -0700 Subject: [PATCH] Don't require @ prefix for attachment filenames --- src/Mailgun/Messages/MessageBuilder.php | 30 +++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Mailgun/Messages/MessageBuilder.php b/src/Mailgun/Messages/MessageBuilder.php index bf33269..c9e53ae 100644 --- a/src/Mailgun/Messages/MessageBuilder.php +++ b/src/Mailgun/Messages/MessageBuilder.php @@ -169,26 +169,22 @@ class MessageBuilder public function addAttachment($attachmentPath, $attachmentName = null) { - if (preg_match("/^@/", $attachmentPath)) { - if (isset($this->files["attachment"])) { - $attachment = array( + if (isset($this->files["attachment"])) { + $attachment = array( + 'filePath' => $attachmentPath, + 'remoteName' => $attachmentName + ); + array_push($this->files["attachment"], $attachment); + } else { + $this->files["attachment"] = array( + array( 'filePath' => $attachmentPath, 'remoteName' => $attachmentName - ); - array_push($this->files["attachment"], $attachment); - } else { - $this->files["attachment"] = array( - array( - 'filePath' => $attachmentPath, - 'remoteName' => $attachmentName - ) - ); - } - - return true; - } else { - throw new InvalidParameter(INVALID_PARAMETER_ATTACHMENT); + ) + ); } + + return true; } public function addInlineImage($inlineImagePath, $inlineImageName = null)