-
-
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
After upgrading to php8.2 and phpmailer 6.8.0: Could not instantiate mail function #2922
Comments
Essentially, you are internally calling the native PHP mail() function and thus do not run the PHPMailer SMTP setup, is that correct? |
Thanks, but I dont' understand - doesn't "$mail = new PHPMailer();" indicate that I wish to use PHPMailer? And if I am using native PHP Mail, how come it is an error in the PHPMailer script that occurs? It is true that the configuration of the SMTP service happens in php ini though. Is that the reason? |
You are using PHPMailer as the builder for sending emails. If you want to make use of the true power of PHPMailer and configure a SMTP relay, you should start with setting: And than also configure this SMTP connection with settings like:
|
Since PHPMailer is calling the native PHP mail() function, the error of calling an undefined / unavailable function is coming from the PHPMailer script. It has nothing to do with PHPMailer itself, it is merely PHPMailer who is responsible for calling this function
SMTP settings to be used for PHPMailer should be explicitly set like I mentioned in my comment above |
Problem description
After upgrading to php8.2 and phpmailer 6.8.0 I get this error message: Could not instantiate mail function.
It worked with php7.4 and phpmailer 6.0.8.
Code to reproduce
I don't use composer, so I include phpmailer like this:
require_once("vendor/phpmailer/phpmailer/src/Exception.php");
require_once("vendor/phpmailer/phpmailer/src/PHPMailer.php");
require_once("vendor/phpmailer/phpmailer/src/SMTP.php");
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
This is the send code:
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->setLanguage('da', 'vendor/phpmailer/phpmailer/language/');
$mail->setFrom('[email protected]', 'Det Kongelige Akademi (kan ikke besvares)');
$mail->addAddress($email,$name);
$mail->isHTML(true);
$mail->Subject = $sub;
$mail->Body = $body;
$mail->send();
Debug output
[26-Jun-2023 15:22:51 Europe/Copenhagen] PHP Fatal error: Uncaught PHPMailer\PHPMailer\Exception: Could not instantiate mail function. in C:\inetpub\wwwroot\oplysningsskema\vendor\phpmailer\phpmailer\src\PHPMailer.php:1966
Stack trace:
#0 C:\inetpub\wwwroot\oplysningsskema\vendor\phpmailer\phpmailer\src\PHPMailer.php(1680): PHPMailer\PHPMailer\PHPMailer->mailSend()
#1 C:\inetpub\wwwroot\oplysningsskema\vendor\phpmailer\phpmailer\src\PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->postSend()
#2 C:\inetpub\wwwroot\oplysningsskema\oplysningsskema.php(489): PHPMailer\PHPMailer\PHPMailer->send()
#3 {main}
thrown in C:\inetpub\wwwroot\oplysningsskema\vendor\phpmailer\phpmailer\src\PHPMailer.php on line 1966
I am convinced that I have made some kind of mistake, but I can't seem to find any clues in the documentation, I have found.
Looking forward to your thoughts.
Thanks, Claus
The text was updated successfully, but these errors were encountered: