What is the easiest way to send an email via Mailchimp's Mandrill service (using the API).
Here's the send method: https://mandrillapp.com/api/docs/messages.html#method=send
Here's the API wrapper: https://bitbucket.org/mailchimp/mandrill-api-php/src/fe07e22a703314a51f1ab0804018ed32286a9504/src?at=master
But I can't figure out how to make an PHP function that will send and email via Mandrill.
Can anyone help?
This is the most basic piece of code I could give you, I just craft it seconds ago for a client and it's working smooth.
Also check their send method for more options like headers, meta-data, attachments etc. https://mandrillapp.com/api/docs/messages.php.html#method-send
Mandrill take HTTP
POST
requests for all of their API methods, and they take your input as a JSON string. Here's a basic example of sending an email. It usescURL
to do the HTTP request:We also have an official API wrapper for PHP, which is available on Bitbucket or via Packagist, which wraps the Mandrill API for you.
If your Mandrill API key is stored as an environment variable, here's a simple example of sending using a template, with some merge variables and metadata:
Include the PHP API: https://bitbucket.org/mailchimp/mandrill-api-php
Code: https://mandrillapp.com/api/docs/messages.php.html#method-send
You can use ZF's autoloading for including the wrapper class or Composer: https://mandrillapp.com/api/docs/index.php.html