On Tue, Jul 20, 2010 at 10:04 PM, Michael Hipp <mich...@hipp.com> wrote:

> I will be sending pdfs generated from django and would like to email them
> but without writing them to the filesystem.
>
> I can generate the pdf to a buffer but django.core.mail seems to only
> handle attachments that are specified as a filename. Is it possible to give
> it a file-like object instead?
>
>
Did you see the documentation regarding creating an EmailMessage and the
attach() method?

It says:

"""You can pass it a single argument that is an
email.MIMEBase.MIMEBaseinstance. This will be inserted directly into
the resulting message."""

Maybe you should create your own message using some of the examples:
http://docs.python.org/library/email-examples.html


Another idea: In what type of operating environment are you? If you are in
linux you can use /dev/shm [0]

In [1]: import tempfile
In [2]: my_file = tempfile.NamedTemporaryFile(dir='/dev/shm/')
In [3]: my_file.name
Out[3]: '/dev/shm/tmpD0tjnI'
In [4]: ls /dev/shm/tmp*
/dev/shm/tmpD0tjnI


[0]
http://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp

hope it helps,

-- 
Ale.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to