Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:57:26+00:00 2026-05-25T12:57:26+00:00

My CakePHP should send an email when a button is clicked, however it doesn’t.

  • 0

My CakePHP should send an email when a button is clicked, however it doesn’t. Also, the email will be displayed as a flash message if I run it in debug mode: ($this->Email->delivery = 'debug';).

Note: Email is set up to set up to use PHP mail() function.

Code to call the email function:

$this->_sendUpdateEmail( $this->Auth->user('id'), $about_id );

Email function

function _sendUpdateEmail($from_user_id, $about_id) {
    $fromUser = $this->User->read(null, $from_user_id);

    $users = $this->User->find('all', array(
        'conditions' => array('User.distribution =' => 1)
    ));

    # loop to send email to all users who are marked as on the distribution list
    for($i = 0, $size = sizeof($users); $i < $size; ++$i) { 
        $user = $users[$i]['User'];

        $this->Email->from = $fromUser['User']['email'];
        $this->Email->replyTo = $fromUser['User']['email'];
        $this->Email->to = $user['email'];
        $this->Email->subject = 'Test email';
        $this->Email->template = 'update';
        $this->Email->sendAs = 'both'; // both = html and text

        $this->set('user', $user);
        $this->set('about', $about_id);

        $this->Email->send();
        $this->Email->reset();
    }
}

Any ideas as to why the emails show in debug mode but won’t actually send?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:57:27+00:00Added an answer on May 25, 2026 at 12:57 pm

    I think the reason why my emails were not sending was because there was no mail server configured on the web server my CakePHP was running on so there was no way to route the emails. However, this meant they would show up in the debug because they were generated successfully, just not sent.

    In the end, I ended up using my company’s Exchange mail server using the SMTP settings.

    Code to use SMTP to send CakePHP emails

    $this->Email->smtpOptions = array(        
        'port'=>'25',         
        'timeout'=>'30',        
        'host' => '192.168.0.244',       
    );
    
    // Other email code here, e.g. from and to etc...
    
    $this->Email->delivery = 'smtp';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CakePHP script that should hopefully be run by a cron job.
I am new to cakephp and I'm trying to accomplish something that should be
In a CakePHP 1.2 app, I'm using <?php $session->flash();?> to output messages like Record
the cakephp rest tutorial says that post data should be in $this->data, but I
The CakePHP ROOT constant, where should it point to?
I'm having a hard time understanding how the CakePHP admin system works. Should all
I am trying to send data over to a cakephp (mvc) website, via $.post().
So, I'm not quite sure how I should structure this in CakePHP to work
While serving images through CakePHP, I'm getting The image http://DOMAIN/PLUGIN/images/image.png cannot be displayed, because
I want to employ CakePHP's basic caching functionality on my site's home page. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.