Dear Alan,
Thank you. Please find my questions and attempts below.
*"create a SQLFORM.factory form and fill the mail.send input with the
values collected on form submission. I guess you could use multiple file
upload fields in the form factory and show or hide them with jQuery
events." *
Can you kindly post a code snippet to demonstrate that?
It is easy to see the code and try to understand it. And even "ReUse" the
code, is possible. It is better to learn things right and elegant from
someone who knows and understands it well than to learn it partially and
broken and inelegantly. So, can you kindly post a code snippet to
demonstrate that?
I tried the following with some half luck – but Attachments do NOT work!
def ComposeMail():
form = SQLFORM <http://127.0.0.1:8000/examples/global/vars/SQLFORM>.factory(
Field <http://127.0.0.1:8000/examples/global/vars/Field>("subject",
requires=IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>()),
Field <http://127.0.0.1:8000/examples/global/vars/Field>("body",
"text", requires=IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>()),
Field <http://127.0.0.1:8000/examples/global/vars/Field>("to",
requires=IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>()),
Field <http://127.0.0.1:8000/examples/global/vars/Field>("attachment",
"upload") )
if form.accepts(request
<http://127.0.0.1:8000/examples/global/vars/request>.vars):
mail.send(
form.vars.to,
form.vars.subject,
form.vars.body,
# attachments = mail.attachment(form.vars.attachment),
)
response <http://127.0.0.1:8000/examples/global/vars/response>.flash =
"Message Sent To : ", form.vars.to
redirect <http://127.0.0.1:8000/examples/global/vars/redirect>(URL
<http://127.0.0.1:8000/examples/global/vars/URL>(f="ConfirmSent"))
return dict(form=form)
def ConfirmSent():
import datetime
message = imapdb(imapdb.Gmail_Sent_Mail.created ==
datetime.date.today()).select().first()
return dict(message=message)
How can I get the values directly from the ComposeMail() in ConfirmSent()
instead of fetching the mail from IMAP server's sent folder?
*"you should use file objects as input instead of the file paths" *
How does one do that in a form in the controller of web2py and pass it to
the *mail.send(...)* function?
*EDIT: To save as draft you need the trunk version and use this syntax:*
*imap.<draft box>.insert(to=..., sender=..., subject=..., attachments=...)*
*# imap is an IMAPAdapter connection*
Great! This is wonderful! Yay!
*"What's the rationale for that?"*
The aim is to learn IMAP and SMTP systems using Python to recreate and
explore the full functionalities of an email system — read, compose, reply,
send, delete, attach files, etc.
IMAP, POP, and SMTP are so commonly used by everyone everyday, and to learn
its workings as well as to use them will be a great thing to learn and
master.
Thank you very much.
*PRACHI*
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.