def get_response(self): """ Creates a Lamson MailResponse instance """ response = MailResponse(Subject=self.subject, To=self.recipients, From=self.sender, Body=self.body, Html=self.html) if self.bcc: response.base['Bcc'] = self.bcc if self.cc: response.base['Cc'] = self.cc for attachment in self.attachments: response.attach(attachment.filename, attachment.content_type, attachment.data, attachment.disposition) response.update(self.extra_headers) return response
def get_response(self): """ Creates a Lamson MailResponse instance """ response = MailResponse(Subject=self.subject, To=self.recipients, From=self.sender, Body=self.body, Html=self.html) if self.cc: response.base['Cc'] = self.cc for attachment in self.attachments: response.attach(attachment.filename, attachment.content_type, attachment.data, attachment.disposition, attachment.transfer_encoding) response.update(self.extra_headers) return response
def get_response(self): """ Creates a Lamson MailResponse instance """ bodies = [self.body, self.html] for idx, part in enumerate(bodies): if not isinstance(part, Attachment): continue base = MailBase() base.body = part.data base.content_encoding["Content-Type"] = (part.content_type, {}) base.content_encoding["Content-Disposition"] = (part.disposition, {}) base.content_encoding["Content-Transfer-Encoding"] = part.transfer_encoding bodies[idx] = base response = MailResponse( Subject=self.subject, To=self.recipients, From=self.sender, Body=bodies[0], Html=bodies[1] ) if self.cc: response.base["Cc"] = self.cc for attachment in self.attachments: response.attach( attachment.filename, attachment.content_type, attachment.data, attachment.disposition, attachment.transfer_encoding, ) response.update(self.extra_headers) return response
def _makeOne(self, **kw): from pyramid_mailer.response import MailResponse return MailResponse(**kw)