我有以下代码:
<?php
include 'swiftmailer/lib/swift_required.php';
//*** Create the Transport ***
$transport = Swift_SmtpTransport::newInstance('smtp.My-Hosting', 25)
->setUsername('MyUserName')
->setPassword('Password');
//*** Create the Mailer using your created Transport ***
$mailer = Swift_Mailer::newInstance($transport);
//*** Create a message ***
$message = Swift_Message::newInstance('NameOfInstance')
->setFrom(array('Support@test.com' => 'John Doe'))
->setTo(array("John@test.com" => "John Smith"))
->setBody('This is a test email message') ;
//*** Send the message ***
$result = $mailer->send($message);
?>
如何在 setFrom、setTo 和 setBody 数组中使用 PHP 变量(即 $email、$name 等)?(我不想输入个人电子邮件/姓名)。