0
我有以下的測試,工作正常製作Swift_Mail類實例
//Create the Transport
$mailer = Swift_Mailer::newInstance($transport);
// create the message
$message = Swift_Message::newInstance('Hello World')
->setFrom(array(MAIL_FROM => MAIL_FROM_NAME))
->setTo(array('[email protected]')
->setBody('Here is the message itself');
//Send the message
$result = $mailer->send($message);
我現在希望把它列入一個類的實例中(例如對象內部的函數發送使用快捷郵件)。我知道我必須重構,但我忽略了這一點。雖然這是錯誤的,我想我試圖說一些沿線
$ mailer = $ this-> Swift_Mailer :: newInstance($ transport);
但我看不出如何重構。你能幫我嗎? 謝謝 Giles
我看不出你的第一個例子有什麼不同。 首先,在代碼中包含swift郵件類,然後實例化swift對象。那很簡單。 – Khronos 2011-12-15 07:11:03