I am using swiftmailer 6.0. When I run that file from url its work perfect but when I run that file from cron job i stuck in errors like very first error is ??
PHP Parse error: syntax error, unexpected '?', expecting
when I remove one ?
than it give me another file and line number which has same ??
I replace all ??
into ?:
than I got stuck into another error which is about try
,catch
& finally
in 4 files the didn't declare catch
after try
they declace finally
directly.
PHP Parse error: syntax error, unexpected 'finally' (T_STRING)
After all the effort I search this issue on stackoverflow and follow this annswer but didn't find any solution and update swiftmail to 6.0.1 but didn't help me out. this is my all code.
require 'Path to/autoload.php';
// //======= SwiftMailer
$transport = (new Swift_SmtpTransport('sever', port,'ssl'))
->setUsername($smtp_email)
->setPassword($smtp_password)
;
$mailer = new Swift_Mailer($transport);
$smtp_message = (new Swift_Message($subject))
->setFrom(['example@any.com' => 'Test Title'])
->setTo($to)
->setBody($message,'text/html')
;
$result = $mailer->send($smtp_message);
Help me out i supend more than 3 hours on it.