我的一个脚本遇到了一个奇怪的问题。 使用此代码发送电子邮件,可以在没有任何错误的情况下发送电子邮件,并且可以在普通Windows计算机,iMac和android移动设备中使用可访问的附件来接收电子邮件。
但是当在iPhone上收到电子邮件时,邮件显示回形针,但根本没有打开附件图标。
有什么建议吗?
// attachment algemene voorwaarden
$check_upload = glob('../uploads/algemene_voorwaarden/*.*');
foreach($check_upload as $val) { $mail->AddAttachment($val); }
// other attachments
$check_upload = glob('../uploads/file_browser/bevestigingen/'.$mail_folder.'/*.*');
foreach($check_upload as $val) { $mail->AddAttachment($val); }
// convert \r\n to new lines
$mail_body = stripcslashes(isset($mail_body) ? preg_replace('#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $mail_body) : false);
$mail_body = str_replace("<br/><br/>","<br/>",$mail_body);
$mail->AddEmbeddedImage('../img/'.$config['logo_mail'], 'header');
$mail->AddEmbeddedImage('../img/mail_logo_torza.png', 'footer');
$mail->Subject = 'Orderbevestiging van '.$config['bedrijf'];
$mail->Body = '<html><head></head>'.
'<body style="margin: 10px;" style="font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#000000;">
<table bgcolor="'.$config['logo_color'].'" width="800" align="center" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><img src="cid:header" width="800"></td>
</tr>
<tr style="padding: 3em;">
<td colspan="2">
'.$mail_body.'
</td>
</tr>
<tr valign="middle">
<td width="50%" align="right"><small><strong>Powered by </strong></small></td>
<td width="50%" align="left"><a href="http://www.torza.nl" target="_blank"><img src="cid:footer" width="50" alt="Torza"></a></td>
</tr>
</table>
</body></html>';
if(!$mail->Send()) { echo'<div class="alert alert-danger text-center" role="alert">Er is helaas iets fout gegaan.</div>'; die; }
答案 0 :(得分:0)
Apple设备上的GitHub官方错误:LINK
Solveta,这是一个iOS错误,不是PHPMailer。您可以使用验证 Gmail或Outlook或其他邮件客户端。发送电子邮件到您的iPhone 带有几个嵌入式图像和一个1MB +的文件,您将 看到该消息将被标记为“已下载为纯文本” 您的iPhone。此行为与消息的大小有关。一世 检查如果消息是<〜500KB,则不会发生这种情况。
(非常)可悲的是,至少在iOS10.x上,即使您单击 在“下载全部消息”上,它将不会显示嵌入的图像 无论如何。解决方法是双击主页按钮,杀死邮件 应用,然后重新打开消息。我已经在Apple网站上打开了2个错误,但 没有答案...(不会对此发表评论)
答案 1 :(得分:0)
发生此问题是因为在页眉和页脚中添加了图像。
$mail->AddEmbeddedImage('../img/'.$config['logo_mail'], 'header');
$mail->AddEmbeddedImage('../img/mail_logo_torza.png', 'footer');
<img src="cid:header" width="800">
<img src="cid:footer" width="50" alt="Torza">
我现在将其更改为
<img src="data:image/jpg;base64,-- BASE 64 STRING -- " />
图像在此处进行了编码:https://www.motobit.com/util/base64-decoder-encoder.asp