Skip to content

Instantly share code, notes, and snippets.

@zircote
Created September 21, 2012 14:39
Show Gist options
  • Save zircote/3761857 to your computer and use it in GitHub Desktop.
Save zircote/3761857 to your computer and use it in GitHub Desktop.
Zend_Mail with inline Zend_Mime_Part
<?php
require_once 'Zend/Mail.php';
require_once 'Zend/Mime/Part.php';
require_once 'Zend/Mail/Transport/Smtp.php';
$config = array(
'name' => 'smtp.gmail.com',
'auth' => 'login',
'username' => '[email protected]',
'password' => 'blahblah',
'ssl' => 'tls',
'port' => 587
);
$mail = new Zend_Mail();
$mail->addTo('[email protected]')
->setFrom('[email protected]')
->setBodyText('text body');
$at = new Zend_Mime_Part(file_get_contents('./public/favicon.ico'));
$at->filename = 'favicon.ico';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_BASE64;
$at->type = 'image/png';
$mail->addAttachment($at);
$mail->send(new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment