Swiftmailer语法错误

时间:2016-04-12 22:53:09

标签: php swiftmailer

我的swiftmailer不断给我语法错误:意外' - >'行->setTo = (array('email@gmail.com', 'email2@yahoo.com'))中的(T_OBJECT_OPERATOR)见下面的代码。

我做错了什么?

<?php
  require_once 'swiftmailer/lib/swift_required.php';

  $to="toemail@gmail.com";
  $subject="Band Request";
  $user_message = $_POST[text];
  $name = $_POST[name];
  $email = $_POST[email];
  $band_request =$_POST[uploaded_file];

  $message = Swift_Message::newInstance()

    ->setSbuject = ($subject)
    ->setTo = (array('email@gmail.com', 'email2@yahoo.com'))
    ->setFrom = ($email)
    ->setBody = ($user_message)
    ->attach(Swift_Attachment::fromPath($band_request))

  ;



  $email_message = "Email: ".$email."\nMessage: ".$message;
  //Set Transport
  $transport = Swift_SmtpTransport::newInstance('localhost');
  //Set Mailer
  $mailer = Swift_Mailer::newInstance($transport);
    // Send the message
  $numSent = $mailer->send($message);

  printf("Sent %d messages\n", $numSent);

  echo "Band Request form has been submitted. <br><a href='../index.html'>Back Home</a>";

 ?>

1 个答案:

答案 0 :(得分:0)

删除->setSubject($subject) 之后的等号:

setSubject

setSubject是一种方法,而不是财产。

(顺便说一句,你在setSbuject中也有一个拼写错误:{{1}}。)