diff --git a/pymailgun/client.py b/pymailgun/client.py index 6369e38..216a56c 100644 --- a/pymailgun/client.py +++ b/pymailgun/client.py @@ -46,11 +46,12 @@ def send_mail(self, sender, to, subject, text, html=None, cc=None, bcc=None, if bcc: data['bcc'] = bcc - if files and isinstance(files, list): - attached_files = [] + attached_files = [] + if files: + if not isinstance(files, list): + files = [files] for f in files: - attached_files.append(('attachment', open(f))) - return self.__request('post', self.domain, 'messages', data=data, - files=attached_files) + attached_files.append(('attachment', open(f, 'rb'))) - return self.__request('post', self.domain, 'messages', data=data) \ No newline at end of file + return self.__request('post', self.domain, 'messages', data=data, + files=attached_files)