Peg Posted March 20, 2016 Share Posted March 20, 2016 (edited) I am just learning how to use PHPMailer. I have not touched anything on any of the PHPMailer files. I am using php 5.2.17 I am surprised to get this error: Parse error: syntax error, unexpected T_FUNCTION in /home/content/33/3333333/html/folder/folder2/PHPMailer/class.phpmailer.php on line 3042 I assumed that this would be something common and I would find another person who had the same issue. Only I do not see anyone with the same error and line as this. I could post my code, but the error comes before any of my code is run. Meaning the php file starts with: date_default_timezone_set('America/Los_Angeles');require 'PHPMailer/PHPMailerAutoload.php'; The error is found before any of my code is run. Edited March 20, 2016 by Peg Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/ Share on other sites More sharing options...
boompa Posted March 20, 2016 Share Posted March 20, 2016 (edited) php 5.2.17 This version of PHP is way too old (end-of-life was over 5 years ago!), and therefore insecure. Version 5.5 is going to reach end-of-life in a few months. You need to upgrade to one of the supported versions: https://secure.php.net/supported-versions.php Edited March 20, 2016 by boompa Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532255 Share on other sites More sharing options...
Peg Posted March 21, 2016 Author Share Posted March 21, 2016 Good point, but I am not ready to update to php 7 yet. The site still uses MySQL functions and I do not have the go ahead to spend the time (and charge them) for changing it. So I actually need to find a version of PHPMailer that will work with php 5.2.17 At least until they are ready to spend the money to pay for me to update their site. Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532261 Share on other sites More sharing options...
Jacques1 Posted March 21, 2016 Share Posted March 21, 2016 Nobody said anything about PHP 7. PHP 5.6 is still actively supported and will reach end-of-life in late 2018. Sticking to PHP 5.2 is not an option and downright suicidal, because it was abandoned back in 2010/2011 and hasn't received any security fixes ever since. Even the dumbest company should understand that. The only exception would be that you get regular security updates through some kind of extended-support operation system (RHEL, CentOS, whatever). Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532264 Share on other sites More sharing options...
Solution mac_gyver Posted March 21, 2016 Solution Share Posted March 21, 2016 (edited) phpmailer should (according to the documentation) work for any php 5+ version (5.4+ if you are using oauth.) however, assuming you are using the latest version of php mailer, that particular section of code IS using php syntax that was introduced in php 5.3 and will throw a parse/syntax error for lower versions. the php version check logic they put in that particular code doesn't have any affect because the code never runs when there is a syntax error. you can edit the section of code for the clearQueuedAddresses method so that it only contains the first set of conditional logic. you could also put the section of code that's in the else{} conditional statement, that's using the php5.3+ syntax, into an external file and require it in place of the in-line code. the require statement will only be executed if the else{} condition is true and this won't throw a parse/syntax error since the code in the required file is only evaluated when the require statement is executed. you can also (at your own risk) download and use older versions of php mailer - https://github.com/PHPMailer/PHPMailer/releases Edited March 21, 2016 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532267 Share on other sites More sharing options...
Peg Posted March 21, 2016 Author Share Posted March 21, 2016 (edited) Thank You!!! Yes, I will update to a newer version. mac_gyver Thank you for a great temporary solution to my problem, and for the clarity of how you explained it! Edited March 21, 2016 by Peg Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532293 Share on other sites More sharing options...
Jacques1 Posted March 21, 2016 Share Posted March 21, 2016 (edited) And now let's hope nobody will hold you accountable for the gigantic security holes you've just opened up. Edited March 21, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301055-phpmailer-error-on-line-3042-classphpmailerphp/#findComment-1532295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.