Introduction to Zend Framework

 Learning Zend Framework

appendix

 Zend Framework Reference


  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    45.6. Attachments

    Files can be attached to an e-mail using the createAttachment() method. The default behavior of Zend_Mail is to assume the attachment is a binary object (application/octet-stream), that it should be transferred with base64 encoding, and that it is handled as an attachment. These assumptions can be overridden by passing more parameters to createAttachment():

    Example 45.8. E-Mail Messages with Attachments

    $mail = new Zend_Mail();
    // build message...
    $mail->createAttachment($someBinaryString);
    $mail->createAttachment($myImage,
                            
    'image/gif',
                            
    Zend_Mime::DISPOSITION_INLINE,
                            
    Zend_Mime::ENCODING_BASE64);

    If you want more control over the MIME part generated for this attachment you can use the return value of createAttachment() to modify its attributes. The createAttachment() method returns a Zend_Mime_Part object:

    $mail = new Zend_Mail();

    $at $mail->createAttachment($myImage);
    $at->type        'image/gif';
    $at->disposition Zend_Mime::DISPOSITION_INLINE;
    $at->encoding    Zend_Mime::ENCODING_BASE64;
    $at->filename    'test.gif';

    $mail->send();

    An alternative is to create an instance of Zend_Mime_Part and add it with addAttachment():

    $mail = new Zend_Mail();

    $at = new Zend_Mime_Part($myImage);
    $at->type        'image/gif';
    $at->disposition Zend_Mime::DISPOSITION_INLINE;
    $at->encoding    Zend_Mime::ENCODING_BASE64;
    $at->filename    'test.gif';

    $mail->addAttachment($at);

    $mail->send();
    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...