# Cannot instantiate abstract class Cake\\Mailer\\Mailer

**URL:** <https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001>\
**Category:** Uncategorized\
**Created:** [February 12, 2021, 6:51am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001 "2021-02-12T06:51:04Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 12, 2021, 6:51am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/1 "2021-02-12T06:51:04Z")

</div>

I want to build forgot password page in cakephp  
Here is my code of user controller  
\<?php

namespace App\Controller;

use App\Controller\AppController;  
use Cake\Http\Exception\UnauthorizedException;

use Cake\Mailer\Email;  
use Cake\Mailer\Mailer;  
use Cake\email\TransportFactory;  
use Cake\Auth\DefaultPasswordHasher;  
use Cake\Utility\Security;  
use Cake\ORM\TableRegistry;  
use Cake\Core\InstanceConfigTrait;

/\*\*

- Users Controller

- 
- @property \App\Model\Table\UsersTable $Users

- 
- @method \App\Model\Entity\User[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])  
\*/  
class UsersController extends AppController {

}

Help me please.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 12, 2021, 4:55pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/2 "2021-02-12T16:55:57Z")

</div>

You will in general get much better help if you include only relevant details. Not too much, but not too little. For example, here the “index” and “add” and “view” and “edit” and “delete” functions are probably unrelated to what you’re trying to do. Why include them?

Your code is also not all formatted well, for some reason, which makes it hard to read, and therefore harder to help.

Lastly, you say you want to “build forgot password page”, but you don’t say what your specific problem is. You have “forgotpassword” and “resetpassword” functions here. Do they not work? If not, what, specifically, fails? Or do you need help making a template? You haven’t shown what the templates for these pages look like, so we don’t know whether you just don’t have them at all, or if there’s some problem with how you’ve set up those forms, for example.

And really truly lastly, calling people out by name is, I think, a little rude. Help here is given voluntarily by people donating their time to help others. By naming people you are implicitly making a demand on them, which is not a good way to encourage the volunteer behaviour.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 13, 2021, 4:48am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/3 "2021-02-13T04:48:54Z")

</div>

I am facing problem in building forgot password & reset password page this error occurs in forgot password page when user entered their registered email then click on submit then this error occurs " Connection refused".  
I already provide my code if you can help me in building this then please help me.  
add,login,index useful for my website thats why I need them.Currently I only need forgot password & reset password page.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 13, 2021, 6:29am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/4 "2021-02-13T06:29:33Z")

</div>

I’m not disputing that those functions are useful for your site. But they don’t make one bit of difference to your problem, and having that massive block of code is likely preventing people from trying to help you. The key to getting good help is asking a good question. I’ve given you some tips on how to improve your question (note that you can edit it to improve it). You certainly choose not to listen…

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 13, 2021, 8:20am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/5 "2021-02-13T08:20:49Z")

</div>

# SMTP timeout. error

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 13, 2021, 12:36pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/6 "2021-02-13T12:36:57Z")

</div>

connection refused error

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 13, 2021, 3:47pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/7 "2021-02-13T15:47:03Z")

</div>

So the error isn’t “Cannot instantiate abstract class”? It’s like you’re actively trying to make it harder to help you solve this problem instead of easier…

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 13, 2021, 4:04pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/8 "2021-02-13T16:04:08Z")

</div>

Yes I am working on this would you like to help me by suggesting some answer.  
Its my battle with this since from last 46 days I search & try each every solutions on google related to cakephp on forgot password page but nothing works.

---

<div class="post-metadata">

**Author:** ![gvouliakis](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/gvouliakis/32/2124_2.png) [@gvouliakis](https://discourse.cakephp.org/u/gvouliakis)\
**Post date:** [February 13, 2021, 9:26pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/9 "2021-02-13T21:26:26Z")

</div>

> [@pawan](#):
>
> $mailer-\>Transport(‘Smtp’);

Is better to read the book here [Mailer - 4.x](https://book.cakephp.org/4/en/core-libraries/email.html#configuring-transports) for version 4.x or here [Email - 3.10](https://book.cakephp.org/3/en/core-libraries/email.html#configuring-transports) for version 3.x and also explore config/app.php file to configure your ‘EmailTransport’ section properly.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 14, 2021, 1:32am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/10 "2021-02-14T01:32:22Z")

</div>

Thanks for your reply I will tried them once again.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 14, 2021, 10:03am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/11 "2021-02-14T10:03:39Z")

</div>

I tried them but none of them working.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 14, 2021, 10:05am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/12 "2021-02-14T10:05:48Z")

</div>

> [@pawan](#):
>
> $mailer-\>Transport(‘Smtp’);

I tried them but none of them working.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 14, 2021, 10:06am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/13 "2021-02-14T10:06:41Z")

</div>

I tried your suggestion earlier none of them working.

---

<div class="post-metadata">

**Author:** ![pawan](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@pawan](https://discourse.cakephp.org/u/pawan)\
**Post date:** [February 14, 2021, 10:08am UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/14 "2021-02-14T10:08:10Z")

</div>

Despite of giving answer to my problem you only giving me speech please I don’t need them. I need solution if you have then please told me otherwise don’t waste your or my time too.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 14, 2021, 3:15pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/15 "2021-02-14T15:15:55Z")

</div>

Sorry you feel that way. I’m actually trying to help you to get a solution. Because the question is pretty much unanswerable as it stands. There are things you can do to improve the chances of that. If you don’t want to listen to that advice, that’s entirely your prerogative, but it shouldn’t be surprising then when a solution doesn’t appear.

---

<div class="post-metadata">

**Author:** ![robertkendrick](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@robertkendrick](https://discourse.cakephp.org/u/robertkendrick)\
**Post date:** [February 16, 2021, 1:13pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/16 "2021-02-16T13:13:45Z")

</div>

As Zuluru says, the lack of relevant information makes this hard to diagnose.  
So guessing some suggestions.  
Assuming you can’t send any emails at all, and the transport is correctly set with proper port, security etc I would switch OFF your antivirus software temporarily and see if that solves the problem.  
AVG is known to cause problems in this respect.

---

<div class="post-metadata">

**Author:** ![dmuenstermann](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@dmuenstermann](https://discourse.cakephp.org/u/dmuenstermann)\
**Post date:** [February 17, 2021, 12:24pm UTC](https://discourse.cakephp.org/t/cannot-instantiate-abstract-class-cake-mailer-mailer/9001/17 "2021-02-17T12:24:28Z")

</div>

I suppose the problem is **more related to you server setup then cakephp**.  
However, you wrote the error is “SMTP timeout”, so I’d suggest the following:

- Check if you can send emails using that configuration directly from your server (e.g. using sendmail on linux systems)

if that works:

- Check Email-configuration named “default” - you use it, but is it configured properly?

else:

- It may be that (depending on your cloud-provider/ISP) communicating to email-servers on specific ports (like 25, 587) is blocked anyway. Check with your cloud-provider/ISP on how to proceed here.

Just some thoughts from a sysadmin.

Last but not least: “speech” is important on a platform like this. People like Zuluru take much time trying to help others but feeling like this isn’t honored from questioners by, for example, formatting code properly or being rude isn’t funny. You don’t want to do non-funny things either.
