Skip to content

Commit

Permalink
Merge pull request #133 from d4mation/master
Browse files Browse the repository at this point in the history
Allow String Attachments. Referencing #132
  • Loading branch information
rajumsys committed Oct 31, 2017
2 parents eb41d01 + a414aba commit 7f13ec0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mailer.http.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,16 @@ protected function encode_attachment($data)
return base64_encode($data);
}

protected function read_attachment($path)
protected function read_attachment($data)
{
return file_get_contents($path);
// If the provided String is a File Path, load the File Contents. If not, assume the String is the contents
// This allows PHPMailer's addStringAttachment() method to work thereby avoiding the need to store a file on the server before attaching it
if ( is_file( $data ) ) {
return file_get_contents($data);
}
else {
return $data;
}
}

public function isMail()
Expand Down

0 comments on commit 7f13ec0

Please sign in to comment.