CHAPTER 16 ■ ADVANCED ZEND FRAMEWORK^253If you do not have a local mail server/mail relay and want to send mail via the Simple Mail
Transfer Protocol (SMTP), the framework provides an interface for this. Listing 16-19 shows
an example.Listing 16-19. Sending Mail via SMTP$transport = new Zend_Mail_Transport_Smtp(
'mail.domain.com',
array(
'auth' => 'login',
'username' => 'myusername',
'password' => 'password'
)
);The auth parameter controls how authentication information is passed to the SMTP server. It
can be can be plain, login, or cram-md5. To integrate the transport with the previous example,
replace the final send() call in Listing 16-18 with send($transport).
You can also use Zend_Mail_Transport_Sendmail when you need to pass additional options
to your sendmail-compatible mailer. Adding an -f option is often critical for correct delivery
headers when sending mail with a sendmail interface.■Note See the Zend Framework reference manual at http://framework.zend.com for more details
about the advanced functionality that is available for sending mail.Creating PDF Files
The Zend_Pdf component allows you to create or modify a PDF file in PHP code. It supports
various image formats, fonts, and some basic drawing.
Creating a PDF from scratch is simple. Just create a new instance of Zend_Pdf:$pdf = new Zend_Pdf();If you want to modify a PDF, simply use the static load function:$pdf = Zend_Pdf::load('/path/to/load/file.pdf');To save a PDF, either new or modified, call save():$pdf->save('/path/to/save/file.pdf');To return a string containing the binary data, such as for output directly to a browser,
call render():$pdf->render();All PDF documents have pages. You can retrieve pages, create new ones, and draw shapes,
fonts, and images to them. When you load an existing PDF, a collection property called pagesMcArthur_819-9C16.fm Page 253 Friday, February 29, 2008 5:07 PM