PhPmailer is not working, but there are no errors

Commenting is not an issue for me, one thing I love about myself is that I can understand HTML and PHP pretty well without comments (One cannot say the same for CSS though, I use comments galore in that.)

A few things to check:

  1. The PHP file is in the same directory as the HTML file and is called exactly “Nachhilfelehrer-login.php” (Note that filenames are case sensitive)

  2. “Less Secure Apps” is enabled in your Google Account Settings

  3. You are using an App Password (Not the password you use to sign in to Google), and have 2Fa enabled.

not working at all… :frowning:

What’s this console_log function? Did you verify that this function can correctly produce output? If it didn’t, that would explain why you don’t see anything.

Could you perhaps try using PHP functions directly (like echo, var_dump(), etc.) to try to generate some output?

Also, like Greenreader said, not using 2FA when using Gmail also tends to break. Gmail is quite protective like that.

1 Like

Nothing

The more information you provide, the better we can help you. If you just say “not working” and “nothing”, there is “nothing” we can do for you.

2 Likes

then im sorry, but it displays nothing. There are no additional information i can give you. But Thanks!

That’s very odd because your PHPMailer code is configured to either say sent if it succeeded or not sent if it did not succeed. If you don’t see either of those things, something else than just a PHPMailer error is occurring.

1 Like

First: thanks for your help! When I use the function, every html code after it is no longer executed. In the console was this error:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

So did i integrate the files wrong? ive already searched for this error, but i found nothing with php.
Thanks

Actually, HTTP error 500 means your PHP code crashed. See below.

2 Likes

I got an error! Its this:
Fatal error : Uncaught Error: Class ‘src\PHPMailer’ not found in /home/vol18_2/epizy.com/epiz_29234248/htdocs/mailsenden.php:16 Stack trace: #0 /home/vol18_2/epizy.com/epiz_29234248/htdocs/Passwort-vergessen.php(41): mailsenden() #1 {main} thrown in**/home/vol18_2/epizy.com/epiz_29234248/htdocs/mailsenden.php** on line16

So what to do right now? In line 16 is $mail = new Phpmailer();

Make sure

is present

But it is present. at the start of the file:

use src\PHPMailer;
use src\SMTP;
use src\Exception;

require ‘vendor/autoload.php’;

For one thing, I think you have the wrong slash, it should be a back slash and not a forward slash.

Second, can you please tell me the location of the file with the forum? (Is it in a sub-folder perhaps?)

Parse error : syntax error, unexpected ‘/’, expecting ‘;’ or ‘,’
this is the error when im using / and: https://github.com/PHPMailer/PHPMailer
here phpmailer is using also .

the folder src is in htdocs/src/PHPMailer
and the file mailsenden.php is in htdocs/mailsenden.php

If I go to Schuelerhelfenschuelern.rf.gd/src/PHPMailer I get a 404 error, however, Schuelerhelfenschuelern.rf.gd/src/PHPMailer.php returns a valid file. Make sure you have the file paths correct!

I got an empty site with: http://schuelerhelfenschuelern.rf.gd/src/PHPMailer.php
So im thinking its correct, isnt it?

Yes, but here:

There is no .php, so a 404 error will be returned.

Hello Greenreader 9 and everyone else, who helped me,
with this:

use src\PHPMailer;
use src\SMTP;
use src\Exception;

nothing worked, even if the path is correct. So i was trying to use my older version from the localhost:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

I dont know why it is working right now, but it is working. I found in the localhost file no folder with the name PHPMailer, even if it is a hidden folder. So I dont know what was wrong.
Thanks for your help, especially with the Alter PHP Directives.
Origamifreddi

2 Likes

I think you may be mixing up the include/require and use statements.

First of all, if you’re using Composer, the Composer include should normally be the very first thing of your code. Putting the use statements before the require that actually loads in the class definitions will not work.

Additionally, the use statements refer to PHP namespaces, which don’t automatically map to system paths. The namespace of a class is defined in the PHP code itself. So that’s always \PHPMailer\PHPMailer\PHPMailer, regardless of how your project is actually laid out.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.