Skip to content

Commit

Permalink
Fix bad return for failed attachment
Browse files Browse the repository at this point in the history
Add test for failing attachment
  • Loading branch information
Synchro committed Jun 6, 2013
1 parent d852751 commit 2032af0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1806,9 +1806,7 @@ public function AddAttachment($path, $name = '', $encoding = 'base64', $type = '
if ($this->SMTPDebug) {
$this->edebug($e->getMessage()."\n");
}
if ( $e->getCode() == self::STOP_CRITICAL ) {
return false;
}
return false;
}
return true;
}
Expand Down
8 changes: 6 additions & 2 deletions test/phpmailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ function tearDown()

/**
* Build the body of the message in the appropriate format.
*
* @private
* @returns void
* @return void
*/
function BuildBody()
{
Expand Down Expand Up @@ -202,7 +203,7 @@ function BuildBody()
/**
* Check which default settings have been changed for the report.
* @private
* @returns void
* @return void
*/
function CheckChanges()
{
Expand Down Expand Up @@ -769,6 +770,9 @@ function test_HTML_Attachment()
return;
}

//Make sure that trying to attach a nonexistent file fails
$this->assertFalse($this->Mail->AddAttachment(__FILE__.md5(microtime()), 'nonexistent_file.txt'));

$this->BuildBody();
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
}
Expand Down

0 comments on commit 2032af0

Please sign in to comment.