Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot declare class PHPMailer\PHPMailer\Exceptions, because the name is already in use in C:\Directory\PHPMailer\src\Exception.php on line 23 #2899

Closed
6 tasks
SohaibKhaliq opened this issue Apr 27, 2023 · 5 comments

Comments

@SohaibKhaliq
Copy link

SohaibKhaliq commented Apr 27, 2023

Please check these things before submitting your issue:

  • Read the error message you're seeing - it often tells you what is wrong, and may contain useful links & instructions
  • Make sure you're using the latest version of PHPMailer
  • Check that your problem is not dealt with in the troubleshooting guide, especially if you're having problems connecting to Gmail or GoDaddy
  • Include sufficient code to reproduce your problem
  • If you're having an SMTP issue, include the debug output generated with SMTPDebug = 2 set
  • If you have a question about how to use PHPMailer (rather than reporting a bug in it), tag a question on Stack Overflow with phpmailer, but search first!

Problem description

Code to reproduce

Debug output

@SohaibKhaliq
Copy link
Author

I have developed a secure php oop based login system. For procedural php, it is working fine, but when i started developing using oop it is struck there. Fix it please!!

@Synchro
Copy link
Member

Synchro commented Apr 27, 2023

Your comment makes no sense. PHPMailer is a class, and you can't really use it in any way that's not "OOP". From the error message, it looks like you've made a mistake related to namespaces, but I can't tell because you have not shown your code, and you're demanding I fix a problem that you created, and have not provided sufficient information about.

@XL-2000
Copy link

XL-2000 commented Apr 27, 2023

@SohaibKhaliq there is no code to look at, so no way to find out what you are doing here...
The "problem" of redeclaration is not a PHPMailer problem; it is your own implementation that is redeclaring stuff.
So in general, this is not a problem caused by PHPMailer nor fixed.

With no code to go by; I am totally shooting in the dark in what might be wrong on your end...
I would put money on either or all of these:

  • You are not using composer
  • You are requiring or including or loading classes yourself
  • You are doing odd things with namespaces / USE
  • Anything else on your end causing this collision

Maybe providing some code might help here....

@lindiii
Copy link

lindiii commented Jun 22, 2023

When i check for the errors i have this:

ParseError

Message

syntax error, unexpected 'public' (T_PUBLIC), expecting case (T_CASE) or default (T_DEFAULT) or '}'

Error at

app/lib/vendor/phpmailer/phpmailer/src/PHPMailer.php, line: 2850

Backtrace

File: app/lib/vendor/composer/ClassLoader.php
Line: 344
Function: Composer\Autoload\includeFile
File: app/Tygh/Mailer/Transports/PhpMailerTransport.php
Line: 33
Function: loadClass
File: app/lib/vendor/composer/ClassLoader.php
Line: 476
Function: include
File: app/lib/vendor/composer/ClassLoader.php
Line: 344
Function: Composer\Autoload\includeFile
File: app/Tygh/Providers/MailerProvider.php
Line: 64
Function: loadClass
File: app/Tygh/Mailer/TransportFactory.php
Line: 74
Function: Tygh\Providers{closure}
File: app/Tygh/Mailer/Mailer.php
Line: 142
Function: createTransport
File: app/Tygh/Mailer/Mailer.php
Line: 74
Function: getTransport
File: app/Tygh/Providers/MailerProvider.php
Line: 54
Function: __construct
File: app/lib/vendor/pimple/pimple/src/Pimple/Container.php
Line: 118
Function: Tygh\Providers{closure}
File: app/Tygh/Application.php
Line: 135
Function: offsetGet
File: app/Tygh/Providers/EventDispatcherProvider.php
Line: 224
Function: offsetGet
File: app/lib/vendor/pimple/pimple/src/Pimple/Container.php
Line: 118
Function: Tygh\Providers{closure}
File: app/Tygh/Application.php
Line: 135
Function: offsetGet
File: app/Tygh/Notifications/Transports/TransportFactory.php
Line: 43
Function: offsetGet
File: app/Tygh/Notifications/EventDispatcher.php
Line: 109
Function: create
File: app/functions/fn.users.php
Line: 4174
Function: dispatch
File: app/controllers/common/auth.php
Line: 183
Function: fn_recover_password_generate_key
File: app/functions/fn.control.php
Line: 722
Function: include
File: app/functions/fn.control.php
Line: 458
Function: fn_run_controller
File: index.php

@Synchro
Copy link
Member

Synchro commented Jun 22, 2023

@lindiii your report has nothing to do with this issue.

That sounds like either you're running a really old version of PHP, or there are errors in the scripts that are loading PHPMailer. PHPMailer itself will not cause this problem.

@Synchro Synchro closed this as completed Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants