Blog Archives

Adding Attachments To Email Using the MailGun.Com PHP API

When sending messages via mailgun I really struggled to add an attachment using the obvious method: $mg = new Mailgun(‘mailgun-api-key’); $msg = $mg->MessageBuilder(); $msg->setFromAddress($from); $msg->setSubject($subject); $msg->setTextBody($textBody); $msg->addAttachment(‘/var/www/somefile.php’); $mg->post(“{$domain}/messages”, $msg->getMessage()); The solution was to do this…. $mg = new Mailgun(‘mailgun-api-key’); $msg

Tagged with: , ,
Posted in MailGun, PHP, Rackspace