Sending attachments in multipart emails with Zend\Mail
I've written before about how to send an HTML email with a text alternative in Zend\Mail, but recently needed to send an attachment with my multipart email. With help from various sources on the Internet, this is how to do it. use Zend\Mail\Message; use Zend\Mime\Message as MimeMessage; use Zend\Mime\Part as MimePart; use Zend\Mime\Mime; use Zend\Mail\Transport\Sendmail; function sendEmail($to, $from, $subject, $html, $text, $attachments = null) { $message = new Message(); $message->addTo($to); $message->addFrom($from); $message->setSubject($subject); // HTML part… continue reading.