简体   繁体   English

PHP邮件mime和Outlook 2010无标题的附件

[英]PHP mail mime and Outlook 2010 Untitled attachments

I'm using Pears mail mime to send out emails with attachments in php. 我正在使用Pears邮件mime在php中发送带有附件的电子邮件。

http://pear.php.net/package/Mail_Mime/redirected http://pear.php.net/package/Mail_Mime/redirected

It seems Outlook is renaming PDF's to "Untitled..." but it works correctly for gmail, hotmail etc. 看来Outlook正在将PDF重命名为“无标题...”,但它对于gmail,hotmail等可以正常使用。

Prior to this problem I had another problem where Outlook would not show the file as PDF and attach it as text file unless I specifically tell the mime addAttachment the file type 在出现此问题之前,我还有另一个问题,除非我明确告知mime addAttachment文件类型,否则Outlook不会将文件显示为PDF并将其附加为文本文件。

see the code here: 在这里查看代码:

if (endsWith($file,".pdf")) {

     $mime->addAttachment($file,'application/pdf',basename($file));

}
else {

        $mime->addAttachment($file);

}

You can see above I've also tried setting the 3rd argument of addAttachment to set the filename, but that hasn't worked either. 您可以在上面看到,我也尝试过设置addAttachment的第三个参数来设置文件名,但这也没有用。

Outlook does not rename other file types so it's a catch 22 either set no filetype and have Outlook send as txt file or set the filetype and Outlook renames the files to 'Untitled' Outlook不会重命名其他文件类型,因此很麻烦22要么不设置文件类型并让Outlook作为txt文件发送,要么设置文件类型,然后Outlook将文件重命名为“无标题”

ok found out that Outlook doesn't seem to like long filenames, shortening the filename works. 好的发现Outlook似乎不喜欢长文件名,缩短文件名是可行的。

Pear mime sends a long filename header broken up into parts like this: Pear mime发送一个长文件名标头,分成以下部分:

Content-Transfer-Encoding: base64
Content-Type: application/pdf;
name*0*=US-ASCII''THIDSO5749_010.901%20-%2013.95505142_GARUDA%20RETARGETI;
name*1*=NG%20CPA%20CAMPAIGN_PT%20GARUDA%20INDONESIA%20%28PERSERO%29%20TBK;
name*2*=._NOV2013.pdf
Content-Disposition: attachment;
filename*0*=US-ASCII''THIDSO5749_010.901%20-%2013.95505142_GARUDA%20RETAR;
filename*1*=GETING%20CPA%20CAMPAIGN_PT%20GARUDA%20INDONESIA%20%28PERSERO;
filename*2*=%29%20TBK._NOV2013.pdf;
size=68426

Outlook can't handle this but it can handle the format: Outlook无法处理此问题,但可以处理以下格式:

Content-Type: application/pdf;name="a long filename.....pdf"

Unfortunately it seems Pear mime can't send this format without editing the core code of mime.php 不幸的是,Pear mime似乎无法在不编辑mime.php核心代码的情况下发送此格式

So I'm just sending shorter filenames for now 所以我现在只是发送较短的文件名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM