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