def email_responses_send_email(self): body_data_key = "Message.Body.Text.Data" if "Message.Body.Html.Data" in self.querystring: body_data_key = "Message.Body.Html.Data" body = self.querystring.get(body_data_key) source = self.querystring.get("Source") subject = self.querystring.get("Message.Subject.Data") destinations = { "ToAddresses": [], "CcAddresses": [], "BccAddresses": [] } for dest_type in destinations: # consume up to 51 to allow exception for i in range(1, 52): field = "Destination.%s.member.%s" % (dest_type, i) address = self.querystring.get(field) if address is None: break destinations[dest_type].append(address[0]) body = body and body[0] source = source and source[0] subject = subject and subject[0] if not all([body, source, subject]): raise MessageRejectedError( "Must specify all of Body, Subject, Source for the email message" ) LOGGER.debug( "Sending email\nFrom: %s\nTo: %s\nSubject: %s\nBody:\n%s" % (source, destinations, subject, body)) return email_responses_send_email_orig(self)
def email_responses_send_raw_email(self): (source, ) = self.querystring.get('Source', ['']) if source.strip(): return email_responses_send_raw_email_orig(self) raw_data = to_str( base64.b64decode(self.querystring.get('RawMessage.Data')[0])) source = get_source_from_raw(raw_data) if not source: raise MessageRejectedError('Source not specified') self.querystring['Source'] = [source] return email_responses_send_raw_email_orig(self)
def email_responses_send_raw_email(self): (source, ) = self.querystring.get("Source", [""]) if source.strip(): return email_responses_send_raw_email_orig(self) raw_data = to_str( base64.b64decode(self.querystring.get("RawMessage.Data")[0])) LOGGER.debug("Raw email:\n%s" % raw_data) source = get_source_from_raw(raw_data) if not source: raise MessageRejectedError("Source not specified") self.querystring["Source"] = [source] return email_responses_send_raw_email_orig(self)