这是我目前的代码:
$parcels = $api->parcels->get();
$url = (array_values($parcels)[0]['label']['label_printer']);
$goToUrl = $api->getUrl($url);
$goToUrl = str_replace('/api/v2//api/v2/', '/api/v2/', $goToUrl);
print_r($goToUrl);
echo "<br />";
echo $url;
我为什么要使用str_replace()
?因为我打算重定向到$goToUrl
,这是行不通的,因为当前的API给了我错误的链接。
这是我的输出:
https://api_key:api_secret@panel.sendcloud.nl/api/v2/labels/label_printer/1369315
在电子邮件中使用的代码:
$email_body = ("This is Label: " . ($parcel_name) . " |OrderId: " . ($parcel_order_number) . "\n\n See Label: " . $goToUrl );
当前的情况这个网址得到了电子邮件,在邮件中,我希望它是一个可点击的链接,而不是整个网址。即使只是最后一部分也足够好:
label/label_printer/1369315
我见过preg_replace,但以前从未使用过,所以我发现很难理解它。
发布于 2016-03-09 06:03:49
若要在phpmailer中启用HTML,必须使用
$mailer->isHtml(true); //Enables html in the regular body.
或
$mailer->MsgHTML($body); //Enables and SETS the message body with HTML.
有关如何将phpmailer与html /正确配置一起使用的示例/指南,您可以看到http://phpmailer.worxware.com/。
https://stackoverflow.com/questions/35892993
复制