CakePHP: How To Have Consistent SMTP Connection

CakePHP: How To Have Consistent SMTP Connection
Social sharing

It’s necessary to configure an SMTP server that will take care of your email deliveries while setting up a mail client. The process is easy – just add the right SMTP parameters to the settings of your email software & you’re good to go.

SMTP server has a limit for number of requests in a time interval & a max limit for sending emails per connection, which varies as per different service providers.

  • While creating the object of Cake Email utility, we have to pass “persistent = true”.
 $Email = new CakeEmail();
 $Email->config(array('persistent' => true));
  • Change the below file for persistent connection changes.
public function send(CakeEmail $email) {
    $this->_cakeEmail = $email;
    if(!$this->_config['persistent'] || !$this->_socket){
    return $this->_content;
  • Add this function in the CakeEmail file.
public function disconnect() {
public function disconnect(){
  • Disconnect the connection, after emails are sent.

Remember that using a standard SMTP (the one associated to free email providers like Yahoo, Hotmail or Gmail) doesn’t ensure delivery of all your messages, especially if you have a long list of recipients. 

Hope  this article helped configuring an SMTP connection.

Andolasoft has the experience in CakePHP Framework & application development. Planning something on CakePHP? Convert your idea into app. Talk to us Today!


Your recently viewed posts:

Jayadev Das - Post Author

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

    Contact Us

    We’d love to help & work with you

    When do you want to start ?

    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    Exit pop up

    Sad to see you leaving early...

    From "Aha" to "Oh shit" we are sharing everything on our journey.
    Enter your email address to stay up to date with the latest news.
    Holler Box