What is wrong with this PHP script to send mail using Pear Mail?

时间秒杀一切 提交于 2019-11-30 20:49:24

Non-static method Mail::factory() should not be called statically

This is a non-fatal notice coming from PHP because PEAR Mail is prehistoric and hasn't been updated to use the static keyword introduced five years ago in PHP5.

After reviewing the documentation, your call to Mail::factory looks completely correct and normal.

You failed to tell us if if the call to send succeeds or fails. If it's succeeding, but the mail is never being delivered, please check the SMTP server logs. If it's failing, what's the actual error message? The Mail::send documentation includes a comprehensive list of errors.

You might want to consider using a more modern mail sending library, like Swiftmailer.

perhaps it has to do with a missing ampersand?

I notice in documentation examples, the usage of factory looks like this:

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);

Note the assigment using =&

prepended an @ to all pear / mail calls. sometime you may end up with Mail::factory() should not be called statically error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!