I have written a Python script which is send an email with an attachement, but i get always the same error message :
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (552, b'5.3.4 Message size exceeds fixed maximum mess
age size', 'notification@company.com')
How can I change the maximum message size limit on the server to avoid this error message and send my email with the attachement correctly?
I UPDATED MY QUESTION WITH MY CODE:
emailfrom = "myemailadress"
emailto = "1.person"
emailto = "2.person"
fileToSend = "data.csv"
username = "user"
password = "password"
msg = MIMEMultipart()
msg["From"] = emailfrom
msg["To"] = emailto
msg["Subject"] = "subject"
msg.preamble = "subject"
ctype, encoding = mimetypes.guess_type(fileToSend)
if ctype is None or encoding is not None:
ctype = "application/octet-stream"
maintype, subtype = ctype.split("/", 1)
if maintype == "text":
fp = open("data.csv")
# Note: we should handle calculating the charset
attachment = MIMEText(fp.read(), _subtype=subtype)
fp.close()
elif maintype == "image":
fp = open("data.csv", "rb")
attachment = MIMEImage(fp.read(), _subtype=subtype)
fp.close()
elif maintype == "audio":
fp = open("data.csv", "rb")
attachment = MIMEAudio(fp.read(), _subtype=subtype)
fp.close()
else:
fp = open("data.csv", "rb")
attachment = MIMEBase(maintype, subtype)
attachment.set_payload(fp.read())
fp.close()
encoders.encode_base64(attachment)
attachment.add_header("Content-Disposition", "attachment", filename="data.csv")
msg.attach(attachment)
#server = smtplib.SMTP("smtp.gmail.com:587")
server = smtplib.SMTP('smtp.upcmail.hu', 25)
#server.starttls()
#server.login(username,password)
server.sendmail(emailfrom, emailto, msg.as_string())
server.quit()
time.sleep(5)
I don't know how can I change the maximum message size limit on the server, I am using Debian.