using smtp sent large file upto 60MB

moonhkt moonhkt at gmail.com
Tue Dec 4 19:54:32 EST 2012


On 12月5日, 上午4時54分, Chris Angelico <ros... at gmail.com> wrote:
> On Wed, Dec 5, 2012 at 2:41 AM, Laszlo Nagy <gand... at shopzeus.com> wrote:
> > If you still don't want to accept this suggestion, then go ahead! Write a
> > program, send out 100MB emails, and you will see for yourself that it just
> > doesn't work.
>
> But be aware of a few things.
>
> 1) Converting 1MB of binary data into a MIME-packaged email is going
> to result in about 2MB of text. (It's about 1.5MB for base 64
> encoding, which is one of the most common used, plus a bit more for
> structure around it, and rounding up, call it two meg.)
>
> 2) If that 2MB of text is stored as a Python text string, it could
> potentially consume 4MB or 8MB of memory, unless you're on Python 3.3,
> in which case it will be only 2MB..
>
> 3) That 2-8MB has to be contiguous.
>
> 4) Any manipulation of the resulting string - which will quite
> probably happen as it's built, as it gets connected to the email, etc,
> etc, etc - will require even more copies of the string.
>
> So all in all, you need a LOT of memory to do your encoding. That's
> why you're seeing MemoryError - it is simply impossible to attach a
> huge file to an email without using a fair amount of memory. (It's
> possible to use that memory a bit at a time, but since emails are
> generally small, most encoding libraries won't be written to do that.
> This isn't like movie editing, where it's common to work with files
> larger than your RAM.)
>
> ChrisA

Thank for your suggestion.

Machine : AIX
Python version : 2.6.2

I am prepare change UNIX script to Python. smtp and ftp are my first
tasks.

But, when using standard unix command mail and uuencode without this
issue.

Our SMTP can send file more than 60MB. But our notes server can
configured 100MB,30MB or 10MB. My notes Mail box can receive 100MB.

In UNIX, by below command send  smtp mail.
uuencode $xfn $xfn | mail -s "$SUBJECT" $NAME

moonhkt



More information about the Python-list mailing list