Jump to content

PHPMailer error on line 3042 class.phpmailer.php


Go to solution Solved by mac_gyver,

Recommended Posts

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 by Peg
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 by boompa

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.

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).

  • Solution

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 by mac_gyver
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.