【发布时间】:2015-06-08 11:52:32
【问题描述】:
我正在发送带有 php 邮件的 url 列表。问题是只有一个链接被转换了。但是,当我尝试只发送这个链接时 - 它可以工作。
目前结果:
....
https://scontent! .cdninst agram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11049164_453900378092870_2016147159_n.jpg
....
想要的结果
...
https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11049164_453900378092870_2016147159_n.jpg
....
如您所见!并出现一些空格
这是我的代码:
$to = 'my@mail.de';
$subject = 'mySubject';
$arr = json_decode($string, true);
$message = '';
$arr = $arr['data'];
foreach ($arr as &$value) {
$message .= $value.'<br />';
}
$headers = 'From: order@mypage.de' . "\r\n" .
'Reply-To: info@mypage.de' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
字符串如下所示:
$string = '{"data": ["https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11049164_453900378092870_2016147159_n.jpg"]}';
我正在从 json 字符串中解码 url。这在使用单个时效果很好。我目前正在测试大约 30 个链接,只有这一个链接被破坏。
想法?
更新:
使用时:
echo $message;
字符串看起来不错。发送邮件后才会出现问题。
更新 2:完成 $string:
$string = '{"data":[
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11022962_1622439674642143_1096883351_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11022968_805054996198636_1309286009_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11022880_1423922187907036_917404870_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/10986377_1627498740796578_1852142680_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/s150x150/e15/928667_892060397523291_369749441_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xtf1/t51.2885-15/s150x150/e15/11024100_808085365911650_996017863_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e15/11055960_1404015356578720_1277867740_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e15/11055777_816808825080092_1542857273_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e15/11055471_841674382559292_1230638428_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11015498_361414020713408_1088438153_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e15/11008375_798420746919485_1231742350_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/10787706_1073162062697744_958846105_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/s150x150/e15/11055503_1563023603973925_1133173525_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/10413863_1600753446833891_1231697708_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11055726_1574126762827213_1177337723_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xtp1/t51.2885-15/s150x150/e15/11004987_1642603925967855_119269404_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11055693_902276879824326_64336413_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-15/s150x150/e15/11049164_453900378092870_2016147159_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/10946319_803454546417844_1425116400_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/s150x150/e15/11008004_1544347675828229_1335095984_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e15/11008078_330573980474432_104629134_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11189632_1438250796488739_1920042106_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e15/11373935_828515147227862_998871606_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e15/11272073_1601246710147452_2026113921_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11191056_1566823826912605_513606088_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xat1/t51.2885-15/s150x150/e15/11176380_875274085879731_345551882_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e15/11199535_1422045371437335_873505586_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11189551_1581295318796082_2009128397_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11208345_767477406707058_569575819_n.jpg",
"https://2kguzbby0.igsonar.com/hphotos-ak-xfp1/t51.2885-15/s150x150/e15/11193001_381540205362927_573897005_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e15/11208605_1607125916200571_200672539_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11203404_1441230966188039_1468562464_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpt1/t51.2885-15/s150x150/e15/11208226_1607707389487979_2115490962_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s150x150/e15/11189286_415149128646596_1948742113_n.jpg",
"https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e15/11190217_352891078253491_608612571_n.jpg"]}';
【问题讨论】:
-
请发布声明或
$string的var_dump -
是的,因为对于给定的字符串,它工作正常。请提供包含
$string的完整列表? -
您必须对您的消息正文进行 mime 编码。