我使用SwiftMailer類根據我的應用程序的配置(開發或生產)使用php mail()函數或SMTP發送郵件。我的代碼如下所示:Swift_Transport_MailTransport類自5.4.5版開始不再使用,並將在6.0中刪除。使用Sendmail或SMTP傳輸代替
// Default mailer: php mail() function
$this->transport = \Swift_MailTransport::newInstance();
// If a SMTP host is defined
if (isset($_SITE['site_smtp_host'])) {
$this->transport = \Swift_SmtpTransport::newInstance($_SITE["site_smtp_host"], 587)
->setUsername($_SITE["site_smtp_user"])
->setPassword($_SITE["site_smtp_pass"]);
}
由於SwiftMailer 5.4.5我得到這個取消通知:
異常:未知錯誤(16384):自5.4版本Swift_Transport_MailTransport 類已被棄用。 5並將在6.0中刪除。 改爲使用Sendmail或SMTP傳輸。
我應該使用Swift_SendmailTransport
,因爲我正在使用Swift_MailTransport
?它會在相同的環境下工作嗎?它是否也使用php mail()函數?如果沒有,是不是可以使用SwiftMailer的php mail()函數了?