0

I am sending 6 .csv files as attachments through SQL Server Email. But Email is failing with the following message in the database mail log:

Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: DATA length exceeds 52.4MiB limit)

Then I ran the following command to increase the maxfilesize limit 2 GB

EXECUTE msdb.dbo.sysmail_configure_sp 'MaxFileSize', '2147483647'; 

Filesize limit was changed successfully to 2 GB, but still I am getting the same error message.

Following are my file sizes in KBs

File A 213 KB, File B 265 KB, File C 6246 KB, File D 35 KB, File E 60 KB, File F 31371 KB

I am using mail-gun(smtp) to send an email. Email is running successfully without FILE F. But When I attached FILE F, email fails. Why my email is failing when I increased maxfile size to 2 GB. Any Idea?

3
  • 1
    I just tried this with a 91MB .txt file it does not give a direct error on my end. I would look at the mail server side and double check that the configuration changes happened. Commented Jul 11, 2020 at 8:25
  • 7
    It's the SMTP server that rejects too large a message, not SQL Server. Commented Jul 11, 2020 at 9:02
  • 1
    Two things you can do: do you zip the files ? The size reduction could be considerable. Mail servers will reject attachments too large. Caveat: some servers may reject certain files extensions deemed dangerous. The other option is to send one attachment at a time, rather than all at once in a single mail. Or add more logic to regroup several files as long as the combined size remains below a certain threshold (say 20 Mb). Keep in mind that the E-mail itself has overhead and will add a percentage to the final size of the message. Commented Jul 11, 2020 at 16:43

1 Answer 1

5

You mentioned that you're using Mailgun as your mail server. Mailgun's terms page say they limit email sizes:

An individual email message may not exceed the per-message size limit (including attachments) of 25MB or it may be permanently lost.

You'll want to reduce your email sizes to match, or consider using a different SMTP server.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.