Send email to a mailing list using the Mailgun API with cURL

Mailgun provides one of the nicest APIs for email communication.

This example assumes we have a mailing list already created and want to send an email to all recipients via the Mailgun API.

The way to do this is to POST to /messages and use the mailing list address as the recipient address in the API call. Here is the call being made via cURL:

$ curl --request POST \
 --url \
 --form 'from=Name <>' \
 --form "text=My email body" \
 --form "subject=My email subject line" \
 --form \
 --form user=api:MY_API_KEY

Note that this API call uses form fields and not any JSON payload.

A successful response will look something like:

   "message": "Queued. Thank you.",
   "id": "..."


Leave a Reply

Your email address will not be published. Required fields are marked *