Tôi có kịch bản này:Có gì sai với tập lệnh PHP này để gửi thư bằng Pear Mail?
require_once "Mail.php";
$from = "Stephen <[email protected]>";//Google apps domain
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.nvrforget.com";
$username = "[email protected]";
$password = "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>");
}
tôi đến với lỗi này:
Non-static method Mail::factory() should not be called statically
Bất kỳ ý tưởng làm thế nào để sửa lỗi này? Pear Mail được cài đặt trên máy chủ.
Có vẻ chính xác. Bạn có chắc chắn thư viện Pear Mail của bạn đang được đưa vào đúng không? – labue