-
-
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
[5.2.7] Class SMTP not found #113
Comments
If the autoloader is loaded, it should be finding that class. I'd suggest setting a breakpoint in the autoloader to make sure it's being loaded. |
I suspect you are doing this: require 'class.phpmailer.class.php';
$mail = new PHPMailer; What you should be doing is: require 'PHPMailerAutoload.php';
$mail = new PHPMailer; The autoloader does not autoload itself, and it's not the PHPMailer class' job to load it. |
yes sadly forgot to make the changes in my files |
Hi, I have the same problem: Fatal error: Class 'SMTP' not found in /home/nuoviamici.net/public_html/PHPMailer/class.phpmailer.php on line 1147 I did: require 'PHPMailerAutoload.php'; but it doesn't work... |
The autoloader depends on being in the same folder as the classes (as it is in the source) - is that the case for you? |
Thanks for answer. Fatal error: Class 'PHPMailer' not found in /home/nuoviamici.net/public_html/inserisci_cliente.php on line 188 with: require 'PHPMailerAutoload.php'; |
Set a breakpoint in the autoloader so you can check the paths it's looking in. |
It works perfectly in my local webserver, the problem is when I transfer the website to remote webserver |
Do PHP versions match? Is the include_path set correctly/differently in your php.ini? If you can't set a breakpoint, write a small script that just loads PHPMailer and echoes paths from the autoloader. |
Thanks, the hosting company's webserver has a old PHP version, i solved my problem! |
hi Synchro, am also facing the same problem, am new to this mail application. i don't know where to put that require 'PHPMailerAutoload.php'; can u pls help me in this...... |
I've got a prospective solution for older PHP versions in my fork, linked above, that makes use of __autoload instead of the SPL autoloader. Please give that a go and see if it solves your problem. |
Hi Synchro, I am changed that you say but my error not solve please visit this website contact form and see error and please given me solution. http:https://codewavedeveloper.com/Contact_Us.php i don't know what is PHP Version of my webserver. Please do needful for this. |
I can't do anything from outside and frankly your server is not my problem, and I'm not here to teach you PHP. You need to investigate yourself. You can always solve it manually by simply including the SMTP class. |
I have added all file uploaded on server with PHPMailer folder that is create problem to finding the SMTP class ? you suggest require code like this: require 'PHPMailerAutoload.php'; In my file code is: require 'PHPMailer/PHPMailerAutoload.php'; |
That should work fine. The autoload function looks for the class files relative to its own location. If it's still not working, I can only think there is something wrong with your PHP installation; an old version, a badly-set include_path, wrong permissions etc. As I said before - set a breakpoint in the autoloader and see where it's looking. If you can't set a breakpoint, go and download Netbeans. |
below are the my web server php version: 5.2.17 |
Where can i get the version 0f 5.2.7? Thanks |
I already downloaded PHPmailer_5.2.7 and change my code and use "include('PHPMailer-master/PHPMailerAutoload.php');" but still nothing sends. |
sometimes i got problems in class.phpmailer.php (v.5.2.7) |
Did you already have an answer with this @DarkViper or did you already fixed it? I already fixed mine and now its successfully running with the system. |
To solve the issue: "Fatal error: Class 'SMTP' not found in..." in PHP versions 5.1.2 to 5.3.0 you only need to delete last parameter at
and change it as follows:
spl_autoload_register was introduced in PHP 5.1.2 but the third parameter of that function was introduced in PHP 5.3.0. |
The autoloader already takes this into account and does a version check. |
fix "Class 'SMTP' not found" error with latest PHPmailer: PHPMailer/PHPMailer#113 git-svn-id: https://openclerk.googlecode.com/svn/trunk@1476 b12a1112-ca08-e5dd-f792-535eff3abf3b
Hi Synchro I am having a similar problem to those mentioned above. I am trying to use PHPMailer so that I can use AuthSMTP to send emails from my shopping cart (PhotoCart) My web host (Dreamhost) constantly has it's mail servers blocked by hotmail and live.com and it has been suggested that I use authSMTP to prevent this from happening. At the moment I get this error Fatal error: Class 'SMTP' not found in /home/craigstew/photography-perth.com.au/Scripts/class.phpmailer.php on line 1194 I have seen some suggestions you made above but the errors shown above are different to mine so I am not certain if the solution is the same and either way, I am not sure where to put this additional code. My web host shows this in regards to the version of PHP: PHP 5.4 x CGI I would be very grateful for any assistance you could provide. Sincerely Craig Stewart |
Code? Are you loading the autoloader? Have you kept all the PHPMailer files together (as in the download)? Are you using the latest version? |
Hi, Hopefully you can shed some light on this for me :) |
Hi Code… do you mean the file that was asked to create by AuthSMTP, and Dreamhost tutorial also has sample code which I have put below. I have not used this particular code, but did implement the version that AuthSMTP asked me to do to test that their set up would work. (it allows you to send a test email) Problem with the Dreamhost code sample is that I do not know what to call the resultant file and I do not know where to put it. Maybe this is the source of the problem? require("(location of files)/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "localhost"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "your_ssh_username"; // Make sure to replace this with your shell enabled user
$mail->Password = "your_ssh_user_password"; // Make sure to use the proper password for your user
$mail->From = "me@mydomain";
$mail->FromName = "Your Name";
$mail->AddAddress("recipient@theirdomain", "Their Name");
$mail->AddCC("cc@ccdomain");
$mail->AddBCC("bcc@bccdomain");
$mail->AddReplyTo("me@mydomain", "me");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "PHPmailer example";
$mail->Body = "This is a test of email";
if(!$mail->Send()){
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
} |
Woah…. Based on your last post I tried changing the path in my Shopping Cart, (which is called Photocart and is developed by Tim Grissett of PictruesPro.com) to point at the AutoLoader file, not the class.phpmailer.php file that I had been lead to believe was the correct thing before. When I try to send a test mail from the Cart - it says it has been sent. I am not getting them though. So, one problem solved, NEXT! If the cart emails think that they are being sent, but they are not being received anywhere - what likely is the issue now? Cheers Craig |
By code I mean whatever code you are running that's not working! Yes: this line is wrong:
It should be:
Search for 'class.phpmailer.php' in your code and update any lines like that. |
If it's submitting but not arriving: check your spam folder in case it did really arrive, otherwise check your local mail server logs. |
Hi Well, Photocart thinks it is sending, but it is not arriving and it does not appear in the Maildir/New folder on my server which is where emails usually go to die. Looking at my AuthSMTP account, it shows that no emails have been sent though it either, and there should now be 3 from the test order that I just placed and the actual test email that I sent when setting it up in the first place. I will have look at the test email code the AuthSMTP told me to try. When you say search any "search my code and change any lines like that…." I literally have no idea where to look… I presume not the files that I downloaded from your site I guess that you must mean the coding of my actual cart software… but I would not have a clue where to start with that… it is a program that I purchased. I have contacted the developer though. If you possibly have any other ideas, I would be very grateful for your continued help. Thank you Craig |
Yes, it will be within the app - if you point the developer at this ticket they will be able to fix it. It's possible that it's not checking send status and is failing silently for some reason. If you get your authsmtp test script working you can confirm it's not your server that's the problem. |
Thanks, Marcus. I am trying to get the AuthSMTP test script to work now. previously nothing happened, but now at least I get a error message Parse error: syntax error, unexpected 'require' (T_REQUIRE), expecting identifier (T_STRING) in /home/craigstew/photography-perth.com.au/Scripts/authsmtp-test.php on line 8 So I will contact AuthSMTP and see what they have to say about that, and I will contact Tim. Thanks for your assistance, it is genuinely appreciated. Craig |
You could just post the code here - that error is a simple syntax error, probably a mis-paste or something. |
Hi Marcus Thanks, I have also contacted AuthSMTP The code is below, I have just blotted out my AuthSMTP account details. the other change I made to change the port from 25 to 587, as I read on Dreamhosts' PHPMailer Tutorial that port 25 was specifically for Dreamhost mail servers whereas 587 was for connecting to any other mail server. <?php
require("scripts/class.PHPMailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.authsmtp.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "XXXXXXX"; // SMTP username -- CHANGE --
$mail->Password = "XXXXXXXX"; // SMTP password -- CHANGE --
$mail->Port = "587"; // SMTP Port
$mail->From = "[email protected]"; //From Address -- CHANGE --
$mail->FromName = "Bliss Studio"; //From Name -- CHANGE --
$mail->AddAddress("[email protected]", "Example"); //To Address -- CHANGE --
$mail->AddReplyTo("[email protected]", "Bliss Studio"); //Reply-To Address -- CHANGE --
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(false); // set email format to HTML
$mail->Subject = "AuthSMTP Test";
$mail->Body = "AuthSMTP Test Message!";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?> |
OK, so this:
should be:
Many file systems are case-sensitive, so their original line is also likely to fail since the actual file name is Port is an integer so it should be just |
Ok, I made those changes and it give a new error. I just wanted to say, Marcus, I can sort this out with AuthSMTP, this does not seem to be your issue, while I do appreciate your help, I do not want to take advantage of it either. Parse error: syntax error, unexpected '' (T_NS_SEPARATOR), expecting identifier (T_STRING) in /home/craigstew/photography-perth.com.au/Scripts/authsmtp-test.php on line 8 |
Oh, just realised I uploaded the file with my user credentials still blotted out… I will try again |
You've still got some simple syntax error to cause that. Given that |
I get same error with user credentials… My Web host shows that I am using PHP 5.4. |
Well, what's on line 8? Got to be something basic. |
I will forward this to AuthSMTP and see what they make of it. |
Hi Marcus. I have heard from the Cart developer and he has given me the code that sends mail using PHPMailer. Does anything jump out at you? Craig
include_once("$smtp_phpmailer_url");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "$smtp_host";
$mail->SMTPAuth = true;
$mail->Username = "$smtp_username";
$mail->Password = "$smtp_password";
$mail->From = "$smtp_from";
$mail->FromName = "$smtp_from_name";
$mail->AddAddress("$smtp_to");
if($htmlMail == "1") {
$mail->IsHTML(true);
} else {
$mail->IsHTML(false);
}
$mail->Subject = "$subject";
if($htmlMail == "1") {
$send_message = ""."";
$send_message .= $he['e_header'];
$send_message .= nl2br($message);
$send_message .= $he['e_footer'];
$message = $send_message;
}
$mail->Body = "$message";
$mail->Send(); |
Well as this thread has said several times:
This needs to be pointing at the autoloader or the implementor needs to take responsibility for loading classes - in this case he's doing neither, so it's breaking. The way that PHPMailer was doing it before was just wrong, and made it difficult to override and subclass, primary objectives for a library. |
Thanks Marcus, I will pass this to Tim and see what he has to say. It is difficult though, Tim says that the code as he has shown, has worked for years - something that he would know. You say that there are problems - something that you would know. It would seem that you and Tim are both correct and that the problem lays elsewhere. When I point Photocart to The AutoLoader, photocart does seem to think that it is set up correctly but as mentioned above it thinks it sends a test email, but no emails are actually sent, Is it possible that what Tim provided would have worked in the past but would now fail because of changes to PHPMailer - but it is "correct enough" that Photocart thinks it is actually working? I know that there are people using PHPMailer with photocart successfully - one person I know tried very hard to assist me in this - and he is an experienced programmer with a PHP background (though it's not his specialty) Cheers Craig |
The previous behaviour was effectively a bug, since it was a hard-coded dependency on the SMTP class that was not possible to override. It could also interfere with autoloading mechanisms used by other frameworks that may have been including PHPMailer, for example Yii. This bug had been present for a long time, and in this case Photocart was relying on the buggy behaviour - now that it's been fixed (and now the SMTP class can be overridden), it's breaking. As mentioned many times above, the fix is to either take responsibility for loading classes yourself, or to use the provided autoloader. This is really trivial stuff; anyone with even the faintest clue about PHP will have no problem dealing with this. Your messages not arriving is an entirely separate problem. You need to enable debug output, check your mail server logs, check your DNS, firewalls etc. |
Either your DNS is not working, or what you're connecting to has no DNS entry. Either way, it's not PHPMailer's problem, and don't hijack threads that are nothing to do with your question. |
I have the following code: require("PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "my.mx.server"; // SMTP server, i edited for security reasons it is introduced corectly
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Username = '[email protected]';//i edited for security reasons it is introduced corectly
$mail->Password = 'pass';//i edited for security reasons it are introduced corectly
$mail->From = "[email protected]";//i edited for security reasons it is introduced corectly
$mail->AddAddress("[email protected]");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
if(!$mail->Send()) {
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
} but it prints the error:
what am i doing wrong? |
|
Hi Synchro, <?php
require_once('PHPMailer\PHPMailerAutoload.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'gmailid'; // i have written my gmail id as value
$mail->Password = 'password'; // i have password of my mail id
$mail->setFrom("[email protected]", "xyz");
$mail->Subject = "test mail";
$mail->Body = "hi";
$mail->AddAddress("[email protected]");
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
echo "sent";
} else {
$error = 'Message sent!';
echo $error;
}
?> Please suggest the solution for this if any.... |
|
hello synchro, i have a problem. I using a PHPMailer-master. but my SMTP doesnt connect. here my syntax <?php
include('PHPmailer/class.phpmailer.php');
include ('PHPMailer/PHPMailerAutoload.php');
//phpinfo();
$mail = new PHPMailer();
//$mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host = "localhost"; // SMTP server
//IsSMTP(); // send via SMTP
$mail->Host = "ssl:https://re.domain.co.id"; // SMTP server RE
$mail->Mailer = "smtp";
$mail->SMTPAuth = false; // turn on SMTP authentication
$mail->SMTPSecure = 'ssl';
$mail->Port=25;
$mail->Username = "[email protected]"; //
$mail->Password = "*******"; // SMTP password
$webmaster_email = "[email protected]"; //Please don't Reply to this email ID
$email = "recipient @ domian.co.id"; // Recipients email ID
$name = "Meilidyaningtyas C.R"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Admin System Online";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"namawebmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Ini adalah permohonan no. project";
$mail->Body = "Ini adalah email contoh. harap untuk tidak membalas pesan ini."; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?> my problem is, fist, Fatal error: Class 'SMTP' not found in line 1149, then I solve it, and now I found Mailer Error: SMTP connect() failed. What should I do? please help me to solve this problem. |
Instead of posting the same questions over and over again, why don't you read the answers that are already here? Just in case you bother to read this answer:
I'm locking this issue now - if you have a new question that is actually different to what has been covered here, open a new issue. |
Hi
just test the very last 5.2.7 (#112 included) and got the error:
PHP Fatal error: Class 'SMTP' not found in ./lib/phpmailer/class.phpmailer.php on line 1147
But I have the PHPMailerAutoload.php on the directory, so I wonder what is wrong here, I've seen that now because of the autoload, the require class.smtp.php is gone so perhpas this is the issue.....some advice on this please ?
thanks
regards
The text was updated successfully, but these errors were encountered: