0

Am creating a file to send email with swift mailer. I got a error like

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in mail.php on line 4

But it working in xampp localhost

this is my code:

<?php
require_once 'swift/lib/swift_required.php';
$transport = (new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl'))
  ->setUsername('[email protected]')
  ->setPassword('password')
  ;
$mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance('Wonderful Subject')
      ->setFrom(array('[email protected]' => 'Name'))
      ->setTo(array('[email protected]'=> 'A name'))
      ->setBody('Test Message Body')
    ;
$result = $mailer->send($message);
?>

My hosting version is PHP 5.2.17

11
  • stackoverflow.com/questions/13388541/… Commented Jul 4, 2017 at 7:26
  • sift this on server it may be xammp not updated Commented Jul 4, 2017 at 7:27
  • @SebastianBrosch: Thank you to sharing this link already i tried this but same error Commented Jul 4, 2017 at 7:29
  • You tried what exactly that's still giving the error? Commented Jul 4, 2017 at 7:29
  • FWIW, you should be upgrading your server from 5.2 to something newer ASAP. PHP 5.2 is ancient and unsupported, meaning it doesn't even receive necessary security updates anymore. Commented Jul 4, 2017 at 7:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.