Send transactional email using Mandrill easily and without hassle
- WordPress 5.x
- PHP 5.3+
- Mandrill PHP SDK
Download and unzip into a subfolder of your
Make sure the folder name is
Inside that folder you'll find the
lib folder. Place the contents of the
src folder from the Mandrill PHP SDK inside it. You should have both
Mandrill.php and a
Mandrill folder directly inside
Then get the
cacert.pem file from this page and upload to the root of the
wp-mandrill-mailer folder on your WordPress instance.
Now, in your WordPress go to the Dashboard and then to Plugins, find the Placeholders plugin and activate it.
Then again in the Dashboard, go to Mandrill Mailer and enter your API key and Pool name (you may enter
Main Pool to use the default pool).
First create a message using the
# Create a MandrillMessage object and set the subject, from, to, contents, attachments, etc. $message = MandrillMessage::newInstance() ->setSubject('Test') ->setFrom( array('email@example.com' => 'Me') ) ->setTo( array('firstname.lastname@example.org' => 'Me') ) ->setTemplate(get_template_directory() . '/templates/mailing/default.mailing.html') ->setImages(array('email_header' => get_template_directory() . '/images/mailing/header.jpg')) ->setAttachments(array('Test.pdf' => get_template_directory() . '/files/test.pdf')) ->setReplacements(array('%email-footer%' => 'Test')) ->setContents('<h2>Hey you</h2>');
Then just send your message:
The function will either return
TRUE if the mail was sent successfully and
Author: biohzrdmx <github.com/biohzrdmx>
Did you find this project useful?
Then you may want to support me by buying me a coffee!