从 php 下载 gmail 附件
您能告诉我如何使用 php 从 gmail 帐户下载附件吗? 谢谢
can you please tell , how to download attachments from gmail account using php ?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 php pop 或 imap 客户端获取邮件并从中提取附件
you could use a php pop or imap client and fetch the mail and extract the attachments from that
正如其他回答者所述,建议使用 IMAP 解决方案,可以在 http://davidwalsh.name/ 找到gmail-php-imap。确保检查您的防火墙,并在 PHP 安装中启用 OpenSSL 和 IMAP。
http://www.electrictoolbox.com/extract-attachments-email-php- imap/ 有关于如何使用
imap_fetchstruction
分析每封电子邮件的结构的优秀代码参考。每条消息的结构中都包含附件。用户在 http://www.php.net/manual/ 贡献了注释en/function.imap-fetchstruct.php 特别有用(正如文档一样)。基本上,您必须
不同的电子邮件客户端的结构会略有不同,但只要稍加努力,就不会太难。然后可以按照您选择的方式处理数据。
As stated by other answerers, an IMAP solution is recommended, and can be found at http://davidwalsh.name/gmail-php-imap. Make sure to check your firewall, and enable the OpenSSL and IMAP in your PHP installation.
http://www.electrictoolbox.com/extract-attachments-email-php-imap/ has excellent code references regarding how to analyze each email's structure using
imap_fetchstructure
. In the structure of each message lie the attachments. The user contributed notes at http://www.php.net/manual/en/function.imap-fetchstructure.php are particularly helpful (as is the documentation).Basically, you have to
Different email clients will have slightly different structures, but it's not too hard with a little effort. The data can then be handled however you choose.
IMAP 解决方案
您必须向其添加附件控件,并且您可以阅读此内容,因为它是此源代码 http://davidwalsh.name/gmail-php-imap
IMAP Solution
You must add to it attachment control and you can read this because from it is this source code http://davidwalsh.name/gmail-php-imap