Running PHP5.2.6 +Lemy5 on APACHE 2.0.49 my phpmailer_v5.1 program throws the following error:
‘Parse error: syntax error, unexpected T_ECHO in /home/vg010web02/68/65/2926568/web/lib/phpmailer/phpmailer5/test/class.phpmailer.php on line 533’
The script calling class.phpmailer.php came with phpmailer_v5.1 as an example script. I added parameter values needed for my server.
I understand that T_ECHO often refers to incomplete pairs of (), {}, ‘’, “”, or missing ;’s.
I’ve searched the 1st 600 lines of class.phpmailer.php and my modified mailer script and haven’t found the problem.
_________________________________________________________________
My mailer script is ...
my_test_smtp_advanced_no_auth.php (test_smtp_advanced_no_auth.php as shipped with phpmailer_v5.1 with my parameters added)
-->
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();$contents = 'Test_Msg.html';
$attachment = $_SERVER{'DOCUMENT_ROOT'} . '/PHPfiles/NwsLtr/Nwsltr_pdfs/$EnNL51_60.pdf';
try {
$mail->Host = "smtp.usit.net";
$mail->SMTPDebug = 2;
$mail->AddReplyTo('my@website', 'me');
$mail->AddAddress('friend@friends_email', 'k.friend');
$mail->SetFrom('my@website', 'me');
$mail->AddReplyTo('my@website', 'me');
$mail->Subject = 'PHPMailer Test -- let me know if you get this.';
//$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML(file_get_contents('contents'));
$mail->AddAttachment($_SERVER{'DOCUMENT_ROOT'} . '/auxlib/web07/pix/image001.gif');
//$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
_________________________________________________________________
The error points to line 533 in a ValidateAddress() method of class.phpmailer.php. The method follows ...
public static function ValidateAddress($address) {
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else { <---Line 533
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(???:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(??:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
}
_________________________________________________________________
I was at first suspicious of the preg_match, but it occurs after the error is thrown.
My purpose in this exercise is to repair a crashed registration page on my website by moving to PHP5 and an updated version of phpmailer. I have not succeeded.
Any help will be appreciated.
EdS
‘Parse error: syntax error, unexpected T_ECHO in /home/vg010web02/68/65/2926568/web/lib/phpmailer/phpmailer5/test/class.phpmailer.php on line 533’
The script calling class.phpmailer.php came with phpmailer_v5.1 as an example script. I added parameter values needed for my server.
I understand that T_ECHO often refers to incomplete pairs of (), {}, ‘’, “”, or missing ;’s.
I’ve searched the 1st 600 lines of class.phpmailer.php and my modified mailer script and haven’t found the problem.
_________________________________________________________________
My mailer script is ...
my_test_smtp_advanced_no_auth.php (test_smtp_advanced_no_auth.php as shipped with phpmailer_v5.1 with my parameters added)
-->
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();$contents = 'Test_Msg.html';
$attachment = $_SERVER{'DOCUMENT_ROOT'} . '/PHPfiles/NwsLtr/Nwsltr_pdfs/$EnNL51_60.pdf';
try {
$mail->Host = "smtp.usit.net";
$mail->SMTPDebug = 2;
$mail->AddReplyTo('my@website', 'me');
$mail->AddAddress('friend@friends_email', 'k.friend');
$mail->SetFrom('my@website', 'me');
$mail->AddReplyTo('my@website', 'me');
$mail->Subject = 'PHPMailer Test -- let me know if you get this.';
//$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML(file_get_contents('contents'));
$mail->AddAttachment($_SERVER{'DOCUMENT_ROOT'} . '/auxlib/web07/pix/image001.gif');
//$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
_________________________________________________________________
The error points to line 533 in a ValidateAddress() method of class.phpmailer.php. The method follows ...
public static function ValidateAddress($address) {
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else { <---Line 533
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(???:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(??:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
}
_________________________________________________________________
I was at first suspicious of the preg_match, but it occurs after the error is thrown.
My purpose in this exercise is to repair a crashed registration page on my website by moving to PHP5 and an updated version of phpmailer. I have not succeeded.
Any help will be appreciated.
EdS