Sample code to build rfc822 mail message building

Jorgen Grahn jgrahn-nntq at algonet.se
Sun Aug 7 04:36:38 EDT 2005


On Sat, 6 Aug 2005 08:45:30 +0100 (BST), praba kar <prabapython at yahoo.co.in> wrote:
> Dear All,
>
>        I am new to python world. I have pasted my code
> which I used it to build rfc822 format mails for
...
> Still What way I can improve this code. If anyone find
> error kindly let me know how to correct it.
...
> #This function base I try to build email message
> def create_mail(domain, user, form, from_name):
>     to =  cc =  bcc = subject =  body = ''
>     attachments = []

Document methods with proper grammar, as doc strings, and use more direct
wording:

def create_mail(domain, user, form, from_name):
   """Build and return an RFC 2822 message with (something about
   what the parameters do) and an empty body. (More details.)
   """
   to =  cc =  bcc = subject =  body = ''
   attachments = []

If you feed your code to the 'pydoc' utility, the output should be readable.

Somewhere you also might need to describe what subset of RFC 2822 and MIME
you implement, or what your "mail metaphor" is. Different people think
differently about mails. I, for example, don't know what you mean by
"attachment" -- the MIME RFCs use much richer concepts.

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/                algonet.se>   R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list