PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] Cannot send email in CakePhp

 January 18, 2022     cakephp, email, php     No comments   

Issue

I make API for send email using cakephp. This is my code:

        App::uses('CakeEmail', 'Network/Email');
        $this->autoLayout = false;
        $this->autoRender = false;
        $data = $this->request->data;
        $title = $data['title'];
        $content = $data['content'];   
        $Email = new CakeEmail('smtp');
        $Email->from('myemail@gmail.com');
        $Email->to($data['email'][0]);

        $Email->subject($title);

        $Email->send($content);

And it show error php_network_getaddresses: getaddrinfo failed: No address associated with hostname. Please help me in this case


Solution

The error message indicates that php cannot communicate with the host hostname - this comes from the configuration for that class:

class EmailConfig {
    public $smtp = array(
        'host' => 'hostname', // <---
        ...
    );
}

Either it's badly configured, or the domain name does not resolve.



Answered By - AD7six
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing