Skip to main content

Mailgun

rbt.thirdparty.mailgun.v1


Third-party integration that supports sending email messages using the Mailgun API.

To use the Mailgun integration, store your Mailgun API key as a secret named mailgun-api-key, and use that secret to authenticate to the integration.

Message

A single message sent using the integration.

Created and scheduled using its constructor: await Message.Send(...).

Send

rpc Send(SendRequest) SendResponse

Construct and send an email message using the Mailgun API.

Returns a task_id which can be used for the message to have been sent.

Messages

SendRequest

See Send.

FieldTypeDescription
recipientstringThe email address of the recipient of the message.
senderstringThe email address of the sender of the message.
subjectstringThe subject of the message.
domainstringThe domain to send from.
oneof body.textstringThe body content of the message, as text.
oneof body.htmlstringThe body content of the message, as HTML.

SendResponse

See Send.

FieldTypeDescription
task_idrbt.v1alpha1.TaskIdID of the task scheduled to send the email.

Testing

If your servicer sends emails, you can mock this functionality using reboot.thirdparty.mailgun.servicers.MockMessageServicer. This mock service stores emails in memory, allowing you to verify the emails sent during your tests. Simply pass it as a servicer to the Reboot class servicers list and use the emails_sent list to check the emails sent.

# Some servicer method call, which should send an email.

await MockMessageServicer.emails_sent_sema.acquire()
self.assertEqual(1, len(MockMessageServicer.emails_sent))
note

When using MockMessageServicer, ensure that the mailgun-api-key secret is available in the Secrets servicer.