-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Class 'PHPMailer\PHPMailer\PHPMailer' not found #1703
Comments
Read the readme file that tells you how to load PHPMailer. |
Hey Marcus,
I followed the readme to the letter but I couldn't figure out the issue.
I used an older version of the mailer and that worked instantly for me.
Thanks for getting back to me.
…On Thu 4 Apr 2019, 2:52 p.m. Marcus Bointon, ***@***.***> wrote:
Read the readme file that tells you how to load PHPMailer.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJnwQ9w_diA1iWz1ELUwcmSnyytlSHVLks5vdgOWgaJpZM4cbCTD>
.
|
I'd really recommend not using the old version. 6.0.x should work fine, you just need to understand namespaces. Either way, I can't tell what you're doing wrong if you don't post your code. |
[image: image.png]
I used composer to install PHPMailer, is there any issue there in my code
that could be the cause?
Thanks for your help and I don't want to be bothering you but I have read
all of the documentation and still had the error.
…On Thu, Apr 4, 2019 at 2:58 PM Marcus Bointon ***@***.***> wrote:
I'd really recommend not using the old version. 6.0.x should work fine,
you just need to understand namespaces.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJnwQ309ySlMg86iYXdgETV3-fKPCHlAks5vdgUGgaJpZM4cbCTD>
.
|
Looks like your image upload didn't work - but don't post code as images if that's what you did. Post your code directly in here. |
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
//Server settings
// $mail->SMTPDebug = 2;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.welred.ie'; // Specify main and backup server
$mail->Port = 465; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'Password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = 'Wel Red';
$mail->AddAddress($email, $f_name); // Add a recipient |
That code is correct, which must mean that your composer setup isn't right. Is there a |
Hm. That all looks correct too. In
Perhaps try |
I will try and run that and see what happens.
Thank you.
…On Thu 4 Apr 2019, 4:28 p.m. Marcus Bointon, ***@***.***> wrote:
Hm. That all looks correct too. In vendor/composer/autoload_psr4.php,
there should be a line like this:
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
Perhaps try composer dump-autoload to make it rebuild in the autoloader.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJnwQ8a7Xz6gVbb3pLUXVQ73DFZm0UQRks5vdhobgaJpZM4cbCTD>
.
|
hello, im facing same issue. |
Have you been following the installation instructions in the README at https://github.com/PHPMailer/PHPMailer#installation--loading? |
Yes. I have everything set up according to the instructions.
…On Tue, Feb 7, 2023 at 12:32 PM Niklas ***@***.***> wrote:
Have you been following the installation instructions in the README at
https://github.com/PHPMailer/PHPMailer#installation--loading?
—
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVNRQV3R6XTKM55T7OO2R3WWIXFFANCNFSM4HDMETBQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
|
Uncaught Error:
Failed opening required
'vendor/phpmailer/phpmailer/src/Exception.php' (include_path='.
:/usr/share/php') in /var/www/html/functions.php: 16
Stack trace:
#0 /var/www/html/people/add.php(5): include()
#1 {main
My code is
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/phpmailer/phpmailer/src/Exception.php';
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/phpmailer/src/SMTP.php';
On Tue, Feb 7, 2023 at 12:35 PM Remilekun Arowosaye ***@***.***>
wrote:
… Yes. I have everything set up according to the instructions.
On Tue, Feb 7, 2023 at 12:32 PM Niklas ***@***.***> wrote:
> Have you been following the installation instructions in the README at
> https://github.com/PHPMailer/PHPMailer#installation--loading?
>
> —
> Reply to this email directly, view it on GitHub
> <#1703 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMVNRQV3R6XTKM55T7OO2R3WWIXFFANCNFSM4HDMETBQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
|
I installed with composer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
On Tue, Feb 7, 2023 at 12:40 PM Remilekun Arowosaye ***@***.***>
wrote:
… Uncaught Error:
Failed opening required 'vendor/phpmailer/phpmailer/src/Exception.php' (include_path='.
:/usr/share/php') in /var/www/html/functions.php: 16
Stack trace:
#0 /var/www/html/people/add.php(5): include()
#1 {main
My code is
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/phpmailer/phpmailer/src/Exception.php';
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/phpmailer/src/SMTP.php';
On Tue, Feb 7, 2023 at 12:35 PM Remilekun Arowosaye ***@***.***>
wrote:
> Yes. I have everything set up according to the instructions.
>
> On Tue, Feb 7, 2023 at 12:32 PM Niklas ***@***.***> wrote:
>
>> Have you been following the installation instructions in the README at
>> https://github.com/PHPMailer/PHPMailer#installation--loading?
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <#1703 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/AMVNRQV3R6XTKM55T7OO2R3WWIXFFANCNFSM4HDMETBQ>
>> .
>> You are receiving this because you commented.Message ID:
>> ***@***.***>
>>
>
>
> --
>
> *Remilekun Arowosaye*
> *Full-stack developer*
> *Cybtech*
> https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
>
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
|
Do you see a PHPMailer folder inside your vendor folder? Is there a class mapping line pointing at it (as described in an earlier comment)? Is your vendor folder at the top level of your app? |
Yes there is a class mapping point as well.
On Tue, Feb 7, 2023 at 12:46 PM Remilekun Arowosaye ***@***.***>
wrote:
…
On Tue, Feb 7, 2023 at 12:44 PM Marcus Bointon ***@***.***>
wrote:
> Do you see a PHPMailer folder inside your vendor folder? Is there a class
> mapping line pointing at it (as described in an earlier comment)? Is your
> vendor folder at the top level of your app?
>
> —
> Reply to this email directly, view it on GitHub
> <#1703 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMVNRQS22DKCB7VEHXYUQFDWWIYRDANCNFSM4HDMETBQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
|
Can you show your folder structure? |
here...
…On Tue, Feb 7, 2023 at 1:03 PM Marcus Bointon ***@***.***> wrote:
Can you show your folder structure?
—
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVNRQQGWEIYDDKYNUFVQ2DWWI2YVANCNFSM4HDMETBQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
*Remilekun Arowosaye*
*Full-stack developer*
*Cybtech*
https://www.linkedin.com/in/remilekun-arowosaye-cyberwizard-88a2361b6/
|
I mean a screen shot or something showing how the folders are arranged in your app. I'm trying to establish whether things are in the right place, or whether you have done something like clone PHPMailer instead of installing it. Have you done a |
That's what I sent
The full folder structure.
…On Tue, 7 Feb 2023, 1:10 pm Marcus Bointon, ***@***.***> wrote:
I mean a screen shot or something showing how the folders are arranged in
your app. I'm trying to establish whether things are in the right place, or
whether you have done something like clone PHPMailer instead of installing
it. Have you done a composer dump-autoload?
—
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVNRQTANPDJNWHQ5UZHUE3WWI3TLANCNFSM4HDMETBQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I don't think image attachments work via email in GitHub, so there is nothing visible. You need to use the web interface. |
That all looks correct. Can you also show your instance creation line, |
$mail = new PHPMailer();
I've also tried.
$mail = new PHPMailer/PHPMailer/PHPMailer;
…On Tue, 7 Feb 2023, 6:08 pm Marcus Bointon, ***@***.***> wrote:
That all looks correct. Can you also show your instance creation line, $mail
= ....
—
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVNRQXV5HXYKQOPU3UBWMLWWJ6RNANCNFSM4HDMETBQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
That looks ok (ignoring wrong direction slashes in second example). I can only think that something has gone astray in your composer setup. What happens if you start a new project, simply:
If that succeeds (should print |
Okay. I'll try this tomorrow at work and revert back.
Thank you for your time.
…On Tue, 7 Feb 2023, 6:42 pm Marcus Bointon, ***@***.***> wrote:
That looks ok (ignoring wrong direction slashes in second example). I can
only think that something has gone astray in your composer setup. What
happens if you start a new project, simply:
1. mkdir thing
2. cd thing
3. composer require phpmailer/phpmailer
4. php -r "use PHPMailer\PHPMailer\PHPMailer; require
'vendor/autoload.php'; new PHPMailer(); echo 'ok';"
If that succeeds (should print ok), you know your problem is elsewhere in
your app's config.
—
Reply to this email directly, view it on GitHub
<#1703 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVNRQXHTOEK4CPEKV6QNH3WWKCPLANCNFSM4HDMETBQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Did this and it worked, with no error whatsoever. Now I am confused... |
` function sendEmail($email, $message, $subject, $name, $html): bool{ ` this is inside the functions file and I have the code that sends the mail inside the add_user.php file. That is the function to sends the mail.
|
I finally fixed it. The issue was I had a SEPARATE PHPMailer folder inside
the same folder where the vendor exists.
So it caused some clashes.
On Tue, 7 Feb 2023, 6:45 pm Remilekun Arowosaye, ***@***.***>
wrote:
… Okay. I'll try this tomorrow at work and revert back.
Thank you for your time.
On Tue, 7 Feb 2023, 6:42 pm Marcus Bointon, ***@***.***>
wrote:
> That looks ok (ignoring wrong direction slashes in second example). I can
> only think that something has gone astray in your composer setup. What
> happens if you start a new project, simply:
>
> 1. mkdir thing
> 2. cd thing
> 3. composer require phpmailer/phpmailer
> 4. php -r "use PHPMailer\PHPMailer\PHPMailer; require
> 'vendor/autoload.php'; new PHPMailer(); echo 'ok';"
>
> If that succeeds (should print ok), you know your problem is elsewhere
> in your app's config.
>
> —
> Reply to this email directly, view it on GitHub
> <#1703 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMVNRQXHTOEK4CPEKV6QNH3WWKCPLANCNFSM4HDMETBQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
I Am facing a issue that Class "PHPMailer" not found, I installed PHPMailer through composer. There is no issue in the local environment. but i am facing the issue in production server. Below is the code I am using. require_once APPPATH . '../vendor/phpmailer/phpmailer/src/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; function sendEmail($data) {
Any help is appriciated. |
Um, you put a |
Also there is no MailerDebug property. |
No description provided.
The text was updated successfully, but these errors were encountered: