PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Opening a remote storage

For remote storages the two most popular protocols are supported: Pop3 and Imap. Both need at least a host and a user to connect and login. The default password is an empty string, the default port as given in the protocol RFC.

<?php
// connecting with Pop3
$mail = new Zend_Mail_Storage_Pop3(array('host'     => 'example.com',
                                         
'user'     => 'test',
                                         
'password' => 'test'));

// connecting with Imap
$mail = new Zend_Mail_Storage_Imap(array('host'     => 'example.com',
                                         
'user'     => 'test',
                                         
'password' => 'test'));

// example for a none standard port
$mail = new Zend_Mail_Storage_Pop3(array('host'     => 'example.com',
                                         
'port'     => 1120
                                         
'user'     => 'test',
                                         
'password' => 'test'));

For both storages SSL and TLS are supported. If you use SSL the default port changes as given in the RFC.

<?php
// examples for Zend_Mail_Storage_Pop3, same works for Zend_Mail_Storage_Imap

// use SSL on different port (default is 995 for Pop3 and 993 for Imap)
$mail = new Zend_Mail_Storage_Pop3(array('host'     => 'example.com',
                                         
'user'     => 'test',
                                         
'password' => 'test',
                                         
'ssl'      => 'SSL'));

// use TLS
$mail = new Zend_Mail_Storage_Pop3(array('host'     => 'example.com',
                                         
'user'     => 'test',
                                         
'password' => 'test',
                                         
'ssl'      => 'TLS'));

Both constructors can throw Zend_Mail_Exception or Zend_Mail_Protocol_Exception (extends Zend_Mail_Exception), depending on the type of error.

Zend Framework