使用prestashop Mail::发送外部PHP文件
我试图使用Prestashop Mail::Send-in外部php文件(我们的API端点) 我试着包括config.inc.php和init.php。它看起来像是使用PHP邮件函数的API。但是presta有邮件类,其他Prestashop类工作正常。 我有Prestashop 1.6.1.9和PHP5.6 我有密码:使用prestashop Mail::发送外部PHP文件,php,rest,prestashop-1.6,Php,Rest,Prestashop 1.6,我试图使用Prestashop Mail::Send-in外部php文件(我们的API端点) 我试着包括config.inc.php和init.php。它看起来像是使用PHP邮件函数的API。但是presta有邮件类,其他Prestashop类工作正常。 我有Prestashop 1.6.1.9和PHP5.6 我有密码: class VoucherModel extends baseModel{ // Other methods public function addSubscriber($e
class VoucherModel extends baseModel{
// Other methods
public function addSubscriber($email)
{
$result = Db::getInstance()->insert("mail_subscribers", array(
"email" => pSQL($email)
));
if($result){
$cartRule = "XYZ123";
$sendMail = $this->_sendMail($email, $cartRule);
return $sendMail;
}
}
public function _sendMail($email, $code = "LOVEMANA")
{
$templateVars['{code}'] = $code;
$id_land = Language::getIdByIso('cs');
$template_name = 'sendvoucher';
$title = 'Váše kredity';
$from = Configuration::get('PS_SHOP_EMAIL');
$fromName = Configuration::get('PS_SHOP_NAME');
$mailDir = _PS_THEME_DIR_.'/mails/';
return Mail::Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName);
}
}
但我有一个错误:
Got error 'PHP message: PHP Deprecated: Non-static method Mail::send() should not be called statically, assuming $this from incompatible context in /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php on line 780
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:0
PHP message: PHP 2. Luracast\\Restler\\Restler->handle() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:41
PHP message: PHP 3. Luracast\\Restler\\Restler->call() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:283
PHP message: PHP 4. call_user_func_array:{/home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989
PHP message: PHP 5. v1\\Api->subscribe() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989
PHP message: PHP 6. prestashop->addSubscriber() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/v1/Api.php:1090
PHP message: PHP 7. prestashop->_sendMail() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:764
PHP message: PHP Deprecated: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail.php on line 117
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:0
PHP message: PHP 2. Luracast\\Restler\\Restler->handle() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:41
PHP message: PHP 3. Luracast\\Restler\\Restler->call() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:283
PHP message: PHP 4. call_user_func_array:{/home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989
PHP message: PHP 5. v1\\Api->subscribe() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989
PHP message: PHP 6. prestashop->addSubscriber() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/v1/Api.php:1090
PHP message: PHP 7. prestashop->_sendMail() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:764
PHP message: PHP 8. Mail->send() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:780
', referer: https://beta.drink-mana.com/en/
其他Prestashop类工作正常。(Configuration::get,Product::getPriceStatic)尝试将此方法称为非静态方法 如果您有PHP 5.4+,请尝试使用以下代码:
return (new Mail)->Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName);
或者,如果您的PHP<5.4,请尝试以下方法:
$mail = new Mail();
return $mail->Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName);
Nothing,仍然得到:弃用:不应静态调用非静态方法PEAR::raiseError(),假设第117行/usr/share/php/Mail.php中不兼容上下文中的$this要删除此错误,需要转到文件/usr/share/php/Mail.php并将PEAR::raiseError替换为(新PEAR)->raiseError。我不是舒尔,但它能帮上忙。我没有这样做的权限。