Skip to content

Commit

Permalink
use basename for mail attachment closes #1900
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Jan 29, 2019
1 parent d15fe56 commit 67e2900
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. This projec

### Fixed

+ [#1900](https://github.com/luyadev/luya/issues/1900) Fixed issue when attachment file name is not provided.
+ [#1902](https://github.com/luyadev/luya/pull/1902) Composition component hides alternate url lang codes when hideDefaultPrefixOnly is true and current lang code is default.
+ [#1898](https://github.com/luyadev/luya/issues/1898) Telephone link raises an exception if an invalid telephone number is provided.
+ [#1897](https://github.com/luyadev/luya/issues/1897) Yii_* constants where not available in config files as Yii entry script was loaded after config files.
Expand Down
2 changes: 1 addition & 1 deletion core/components/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function bccAddress($email, $name = null)
*/
public function addAttachment($filePath, $name = null)
{
$this->getMailer()->addAttachment($filePath, empty($name) ? '' : $name);
$this->getMailer()->addAttachment($filePath, empty($name) ? pathinfo($filePath, PATHINFO_BASENAME) : $name);

return $this;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/core/components/MailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,14 @@ public function testAltBodySetBySetter()

$this->assertSame('Bar', $mail->convertMessageToAltBody('<p>Bar</p>'));
}

public function testAttachementPathInfo()
{
$mail = new Mail();
$mail->compose('bar', 'foo');
$file = Yii::getAlias('@app/hashfile.txt');
$mail->addAttachment($file);

$this->assertNotEmpty($mail->getMailer()->getAttachments());
}
}

0 comments on commit 67e2900

Please sign in to comment.