x13*_*x13 2 python gmail executable smtplib
我如何更改可执行二进制文件的真实文件扩展名以通过 gmail smtp 协议(全部在 python 中)发送该文件。
示例:“binary”到“binary.jpg”
我会试试这个:
导入 gzip,shutil
src = 打开('3c7983cb70e9630cc4ee2fe3e1fb16c2','rb')
dest = gzip.open('3c7983cb70e9630cc4ee2fe3e1fb16c2.gz.jpg', 'wb')
Shutil.copyfileobj(src, dest)
但是当我尝试通过 gmail smtp 发送时,发生了这种情况:
smtplib.SMTPDataError: (552, '5.7.0 我们的系统在您的邮件中检测到非法附件。请\n5.7.0 访问 http://mail.google.com/support/bin/answer.py?answer=6590 以\ n5.7.0 查看我们的附件指南。n18sm433437wbh.23')
提前致谢。
根据 Google 的政策,二进制文件是被禁止的。
Gmail won't accept these types of files even if they are sent in a zipped
(.zip, .tar, .tgz, .taz, .z, .gz) format. If this type of message is sent to
your Gmail address, it is bounced back to the sender automatically.
Run Code Online (Sandbox Code Playgroud)
因此,Google 正在解压缩您的文件,并且很可能会检查文件头以确定文件类型(不依赖于提供的扩展名。要解决此问题,您可以尝试将其作为受密码保护的 ZIP 文件上传,因为 google 将无法假设他们允许,将其打开以扫描内容。另一种选择是在发送文件之前对其进行加密,即使是非常简单的 XOR 加密也可能足以通过过滤。然后您需要在检索时解密文件。