diff --git a/docker/integtest/3-receive-email-for-client.sh b/docker/integtest/3-receive-email-for-client.sh index 148e20d4..cd67008a 100755 --- a/docker/integtest/3-receive-email-for-client.sh +++ b/docker/integtest/3-receive-email-for-client.sh @@ -16,9 +16,13 @@ client_id="$(jq -r '.client_id' < "${out_dir}/register1.json")" # this simulates sendgrid delivering an email to the service http --check-status -f POST \ "http://nginx:8888/api/email/sendgrid/${client_id}" \ + "dkim={@sendgrid.com : pass}" \ + "SPF=pass" \ "email=@${email_to_receive}" # simulate delivery of the same email to the second mailbox http --check-status -f POST \ "http://nginx:8888/api/email/sendgrid/${client_id}" \ + "dkim={@sendgrid.com : pass}" \ + "SPF=pass" \ "email=@${email_to_receive}" diff --git a/opwen_email_server/actions.py b/opwen_email_server/actions.py index 4a491a96..bb5c79c3 100644 --- a/opwen_email_server/actions.py +++ b/opwen_email_server/actions.py @@ -198,7 +198,7 @@ def __init__(self, auth: AzureAuth, raw_email_storage: AzureTextStorage, next_ta self._raw_email_storage = raw_email_storage self._next_task = next_task - def _action(self, client_id, email): # type: ignore + def _action(self, client_id, email, **sendgrid_args): # type: ignore domain = self._auth.domain_for(client_id) if not domain: self.log_event(events.UNREGISTERED_CLIENT, {'client_id': client_id}) # noqa: E501 # yapf: disable diff --git a/opwen_email_server/swagger/email-receive.yaml b/opwen_email_server/swagger/email-receive.yaml index 14a9b568..11e5dd95 100644 --- a/opwen_email_server/swagger/email-receive.yaml +++ b/opwen_email_server/swagger/email-receive.yaml @@ -17,7 +17,19 @@ paths: - multipart/form-data parameters: - $ref: '#/parameters/ClientId' - - $ref: '#/parameters/MimeEmail' + - $ref: '#/parameters/SendgridEmail' + - $ref: '#/parameters/SendgridDkim' + - $ref: '#/parameters/SendgridTo' + - $ref: '#/parameters/SendgridCc' + - $ref: '#/parameters/SendgridFrom' + - $ref: '#/parameters/SendgridText' + - $ref: '#/parameters/SendgridSenderIp' + - $ref: '#/parameters/SendgridSpamReport' + - $ref: '#/parameters/SendgridEnvelope' + - $ref: '#/parameters/SendgridSubject' + - $ref: '#/parameters/SendgridSpamScore' + - $ref: '#/parameters/SendgridCharsets' + - $ref: '#/parameters/SendgridSpf' responses: 200: description: The email was successfully received. No need to retry it. @@ -33,9 +45,93 @@ parameters: type: string required: true - MimeEmail: + SendgridEmail: name: email - description: Email represented as a MIME string. + description: A string containing the email headers, date, body, and attachments. in: formData type: string required: true + + SendgridDkim: + name: dkim + description: A string containing the verification results of any DKIM and domain keys signatures in the message. + in: formData + type: string + required: false + + SendgridTo: + name: to + description: Email recipient field as taken from the message headers. + in: formData + type: string + required: false + + SendgridCc: + name: cc + description: Email cc field, as taken from the message headers. + in: formData + type: string + required: false + + SendgridFrom: + name: from + description: Email sender, as taken from the message headers. + in: formData + type: string + required: false + + SendgridText: + name: text + description: Email body in plaintext formatting. + in: formData + type: string + required: false + + SendgridSenderIp: + name: sender_ip + description: Email sender IP address. + in: formData + type: string + required: false + + SendgridSpamReport: + name: spam_report + description: Spam Assassin's spam report. + in: formData + type: string + required: false + + SendgridEnvelope: + name: envelope + description: A string containing the SMTP envelope. This will have 2 variables; to, which is an single-element array containing the addresses that received the email, and from, which is the return path for the message. + in: formData + type: string + required: false + + SendgridSubject: + name: subject + description: Email subject. + in: formData + type: string + required: false + + SendgridSpamScore: + name: spam_score + description: Spam Assassin's rating for whether or not this is spam. + in: formData + type: string + required: false + + SendgridCharsets: + name: charsets + description: A string containing the character sets of the fields extracted from the message. + in: formData + type: string + required: false + + SendgridSpf: + name: SPF + description: The results of the Sender Policy Framework verification of the message sender and receiving IP address. + in: formData + type: string + required: false