Richard Parnaby-King

Web Developer – PHP, Zend Framework and Actionscript 3

Posted on | | 1 Comment

It may be that your server does not allow you to send emails, for example a shared server or localhost that you cannot configure.

In either case, if you are using the Zend Framework’s Zend_Mail component, you can have your application send the emails through GMail.

Configuration

In your application.ini file, add the following:
[c]
;email
email.server = smtp.gmail.com
email.username = username
email.password = password
email.ssl = ssl
email.port = 465
[/c]
Obviously substituting ‘username’ and ‘password’ for your username and password.

In your bootstrap file, add the following _init function.
[php]
getOptions();
$this->_aMailConfig = array(
‘auth’ => ‘login’,
‘username’ => $aConfig[’email’][‘username’],
‘password’ => $aConfig[’email’][‘password’],
‘ssl’ => $aConfig[’email’][‘ssl’],
‘port’ => $aConfig[’email’][‘port’]);
$this->_strSmtp = $aConfig[’email’][‘server’];
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($this->_strSmtp, $this->_aMailConfig));
}
[/php]

You do not need to call this function, your Zend Framework application will call every _init* function in your bootstrap file.

Every email that is sent using the Zend_Mail component will now go through your gmail account. Happy Zending =)

Posted By:

Comments

  • ABOUT

    Having fifteen years of programming experience in PHP, Zend Framework and ActionScript3, I have a very strong working knowledge of object orientated programming.

    I am a PC Gamer! Playing FPS, RTS, RPG and the occasional MMO since 1996 I have a huge number of a variety of fast-paced games.

  • Recent Posts

  • Categories

  • RSS SUBSCRIBE TO OUR FEED