3
我正在使用PHP 5的PEAR Mail擴展。我無法發送郵件,因爲它返回此錯誤:Non-static method Mail::factory() should not be called statically
。使用PEAR Mail擴展時,能否讓PHP忽略靜態方法錯誤?
這是我的代碼:
$from = "Stephen <[email protected]>";
$to = "helper <[email protected]>";
$subject = "Email Test!";
$body = "email test body";
$host = "smtp.nvrforget.com";
$username = "[email protected]";
$password = "*************";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
我無法接收電子郵件。
如果可以的話,我會使用Swiftmailer,但我的網絡主機不讓我。
你不能只上傳swiftmailer文件以及你的其他php文件嗎?網絡主機不應該爲你安裝任何東西。另一個流行的你可以使用的是phpmailer – bumperbox
@bumperbox謝謝!只要把Swiftmailer放在上面,它就像一個魅力:)。 – chromedude